Skip to content

Commit

Permalink
Merge pull request #5828 from veroglez/LPD-1261_name
Browse files Browse the repository at this point in the history
feat(@clayui/card): LPD-1261 Add name to group all radio type inputs
  • Loading branch information
matuzalemsteles authored Jun 4, 2024
2 parents 9b9a1b0 + bd32f54 commit affe1ae
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 15 deletions.
7 changes: 5 additions & 2 deletions packages/clay-card/src/CardWithHorizontal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export interface IProps extends React.BaseHTMLAttributes<HTMLDivElement> {
* Props to add to the radio element
*/

radioProps?: React.HTMLAttributes<HTMLInputElement> & {value: string};
radioProps?: React.HTMLAttributes<HTMLInputElement> & {
name: string;
value: string;
};

/**
* Flag to indicate if card is selected
Expand Down Expand Up @@ -101,7 +104,7 @@ export const ClayCardWithHorizontal = ({
},
href,
onSelectChange,
radioProps = {value: ''},
radioProps = {name: '', value: ''},
selectableType,
selected = false,
spritemap,
Expand Down
7 changes: 5 additions & 2 deletions packages/clay-card/src/CardWithInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export interface IProps extends React.BaseHTMLAttributes<HTMLDivElement> {
* Props to add to the radio element
*/

radioProps?: React.HTMLAttributes<HTMLInputElement> & {value: string};
radioProps?: React.HTMLAttributes<HTMLInputElement> & {
name: string;
value: string;
};

/**
* Description of the file
Expand Down Expand Up @@ -154,7 +157,7 @@ export const ClayCardWithInfo = ({
imgProps,
labels,
onSelectChange,
radioProps = {value: ''},
radioProps = {name: '', value: ''},
selectableType,
selected = false,
spritemap,
Expand Down
7 changes: 5 additions & 2 deletions packages/clay-card/src/CardWithUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ export interface IProps extends React.BaseHTMLAttributes<HTMLDivElement> {
* Props to add to the radio element
*/

radioProps?: React.HTMLAttributes<HTMLInputElement> & {value: string};
radioProps?: React.HTMLAttributes<HTMLInputElement> & {
name: string;
value: string;
};

/**
* Flag to indicate if card is selected
Expand Down Expand Up @@ -134,7 +137,7 @@ export const ClayCardWithUser = ({
spritemap,
stickerTitle,
selectableType,
radioProps = {value: ''},
radioProps = {name: '', value: ''},
userImageAlt = 'thumbnail',
userDisplayType,
userImageSrc,
Expand Down
3 changes: 3 additions & 0 deletions packages/clay-card/src/__tests__/__snapshots__/index.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,7 @@ exports[`ClayCardWithHorizontal renders with radio button 1`] = `
<input
class="custom-control-input"
disabled=""
name="cards"
role="radio"
type="radio"
value="radio1"
Expand Down Expand Up @@ -2917,6 +2918,7 @@ exports[`ClayCardWithInfo renders with radio button 1`] = `
<label>
<input
class="custom-control-input"
name="cards"
role="radio"
type="radio"
value="radio1"
Expand Down Expand Up @@ -3461,6 +3463,7 @@ exports[`ClayCardWithUser renders with radio button 1`] = `
<label>
<input
class="custom-control-input"
name="cards"
role="radio"
type="radio"
value="radio1"
Expand Down
6 changes: 3 additions & 3 deletions packages/clay-card/src/__tests__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ describe('ClayCardWithUser', () => {
href="#"
name="Foo Bar"
onSelectChange={jest.fn()}
radioProps={{value: 'radio1'}}
radioProps={{name: 'cards', value: 'radio1'}}
selectableType="radio"
spritemap="/path/to/some/resource.svg"
/>
Expand Down Expand Up @@ -835,7 +835,7 @@ describe('ClayCardWithHorizontal', () => {
disabled
href="#"
onSelectChange={jest.fn()}
radioProps={{value: 'radio1'}}
radioProps={{name: 'cards', value: 'radio1'}}
selectableType="radio"
selected={false}
spritemap="/path/to/some/resource.svg"
Expand Down Expand Up @@ -1146,7 +1146,7 @@ describe('ClayCardWithInfo', () => {
<ClayCardWithInfo
href="#"
onSelectChange={jest.fn()}
radioProps={{value: 'radio1'}}
radioProps={{name: 'cards', value: 'radio1'}}
selectableType="radio"
selected={false}
spritemap="/path/to/some/resource.svg"
Expand Down
12 changes: 6 additions & 6 deletions packages/clay-card/stories/Card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const CardWithInfo = (args: any) => {
},
]}
onSelectChange={(value) => setRadioValue(value)}
radioProps={{value: 'radio1'}}
radioProps={{name: 'cards', value: 'radio1'}}
selectableType="radio"
selected={radioValue === 'radio1'}
stickerProps={null}
Expand All @@ -132,7 +132,7 @@ export const CardWithInfo = (args: any) => {
},
]}
onSelectChange={(value) => setRadioValue(value)}
radioProps={{value: 'radio2'}}
radioProps={{name: 'cards', value: 'radio2'}}
selectableType="radio"
selected={radioValue === 'radio2'}
stickerProps={null}
Expand Down Expand Up @@ -270,7 +270,7 @@ export const CardWithHorizontal = (args: any) => {
disabled={args.disabled}
href="#"
onSelectChange={setRadioValue}
radioProps={{value: 'radio1'}}
radioProps={{name: 'cards', value: 'radio1'}}
selectableType="radio"
selected={radioValue === 'radio1'}
title="Radio Selectable Folder 1"
Expand All @@ -292,7 +292,7 @@ export const CardWithHorizontal = (args: any) => {
disabled={args.disabled}
href="#"
onSelectChange={setRadioValue}
radioProps={{value: 'radio2'}}
radioProps={{name: 'cards', value: 'radio2'}}
selectableType="radio"
selected={radioValue === 'radio2'}
title="Radio Selectable Folder 2"
Expand Down Expand Up @@ -387,7 +387,7 @@ export const CardWithUser = (args: any) => {
disabled={args.disabled}
name="Abraham Kuyper I"
onSelectChange={setRadioValue}
radioProps={{value: 'radio1'}}
radioProps={{name: 'cards', value: 'radio1'}}
selectableType="radio"
selected={radioValue === 'radio1'}
stickerTitle="User Icon"
Expand All @@ -398,7 +398,7 @@ export const CardWithUser = (args: any) => {
disabled={args.disabled}
name="Abraham Kuyper II"
onSelectChange={setRadioValue}
radioProps={{value: 'radio2'}}
radioProps={{name: 'cards', value: 'radio2'}}
selectableType="radio"
selected={radioValue === 'radio2'}
stickerTitle="User Icon"
Expand Down

0 comments on commit affe1ae

Please sign in to comment.