Skip to content

Commit

Permalink
feat: mixed button
Browse files Browse the repository at this point in the history
  • Loading branch information
sabato-galasso authored Dec 4, 2023
1 parent 53278bd commit 622aef9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 13 deletions.
17 changes: 17 additions & 0 deletions src/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ export const Input = ({

const inputPassword = extraAttributes.type === 'password';

const indeterminateCheckboxInput = type === 'checkbox' && className?.includes('semi-checked')

Check failure on line 207 in src/Input/Input.tsx

View workflow job for this annotation

GitHub Actions / coverage

Replace `·type·===·'checkbox'·&&·className?.includes('semi-checked')` with `⏎····type·===·'checkbox'·&&·className?.includes('semi-checked');`

// Styling
const { activeClass, infoTextClass, inputClasses, wrapperClass } = getClasses(
className,
Expand Down Expand Up @@ -273,6 +275,21 @@ export const Input = ({
);
}

if (indeterminateCheckboxInput) {
return (
<InputContainer {...containerProps}>
<Tag
{...rest}
{...extraAttributes}
{...sharedAttributes}
className={inputClasses}
data-testid={testId}
indeterminate={'true'}
/>
</InputContainer>
);
}

if (inputPassword) {
return (
<InputContainer {...containerProps}>
Expand Down
2 changes: 1 addition & 1 deletion stories/Form/Checkbox.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ Per poter raggruppare gli elementi checkbox occorrerà aggiungere al componente
Per ottenere uno stato di tipo Mixed basterà aggiungere la classe `.semi-checked` al componente Input.

<Canvas>
<Story id='componenti-form-checkbox--checkbox-mixed' />
<Story id='componenti-form-checkbox--checkbox-mixed-button' />
</Canvas>
34 changes: 22 additions & 12 deletions stories/Form/Checkbox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,26 @@ export const CheckboxGruppi = () => (
</section>
);

export const CheckboxMixed = () => (
<Form className='m-3'>
<fieldset>
<legend>Checkbox</legend>
<FormGroup check>
<Input id='mixed-checkbox1' type='checkbox' className='semi-checked' />
<Label for='mixed-checkbox1' check>
Checkbox di esempio
</Label>
</FormGroup>
</fieldset>
</Form>
export const CheckboxMixedButton = () => (
<section>
<Row className='m-5'>
<Col sm="12">

Check failure on line 145 in stories/Form/Checkbox.stories.tsx

View workflow job for this annotation

GitHub Actions / coverage

Replace `····<Col·sm="12"` with `<Col·sm='12'`
<fieldset>

Check failure on line 146 in stories/Form/Checkbox.stories.tsx

View workflow job for this annotation

GitHub Actions / coverage

Replace `············` with `········`
<legend>Checkbox</legend>

Check failure on line 147 in stories/Form/Checkbox.stories.tsx

View workflow job for this annotation

GitHub Actions / coverage

Delete `····`
<Form className='m-3'>

Check failure on line 148 in stories/Form/Checkbox.stories.tsx

View workflow job for this annotation

GitHub Actions / coverage

Delete `····`
<FormGroup check inline>

Check failure on line 149 in stories/Form/Checkbox.stories.tsx

View workflow job for this annotation

GitHub Actions / coverage

Delete `··`
<Input
id='checkbox3'
type='checkbox'
defaultChecked
className="semi-checked"

Check failure on line 154 in stories/Form/Checkbox.stories.tsx

View workflow job for this annotation

GitHub Actions / coverage

Replace `"semi-checked"` with `'semi-checked'`
label="Mixed button attivo"

Check failure on line 155 in stories/Form/Checkbox.stories.tsx

View workflow job for this annotation

GitHub Actions / coverage

Replace `"Mixed·button·attivo"` with `'Mixed·button·attivo'`
/>
</FormGroup>
</Form>

Check failure on line 158 in stories/Form/Checkbox.stories.tsx

View workflow job for this annotation

GitHub Actions / coverage

Replace `··············` with `··········`
</fieldset>

Check failure on line 159 in stories/Form/Checkbox.stories.tsx

View workflow job for this annotation

GitHub Actions / coverage

Delete `····`
</Col>
</Row>
</section>
);

0 comments on commit 622aef9

Please sign in to comment.