Skip to content

Commit

Permalink
fix(elements)!: prefix styled component props in Legend
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
- `disabled` is renamed `$isDisabled` in `Legend` props.
- `hasError` is renamed `$hasError` in `Legend` props.
- `isHidden` is renamed `$isHidden` in `Legend` props.
  • Loading branch information
ivangabriele committed Sep 12, 2024
1 parent 46d1134 commit ef4284a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
7 changes: 6 additions & 1 deletion src/elements/Fieldset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ export function Fieldset({
return (
<Box className={classnames('Element-Fieldset', className)} {...nativeProps}>
{legend && (
<Legend $isRequired={isRequired} disabled={nativeProps.disabled} hasError={hasError} isHidden={isLegendHidden}>
<Legend
$disabled={nativeProps.disabled}
$hasError={hasError}
$isHidden={isLegendHidden}
$isRequired={isRequired}
>
{legend}
</Legend>
)}
Expand Down
10 changes: 5 additions & 5 deletions src/elements/Legend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import styled from 'styled-components'
import type { HTMLAttributes } from 'react'

export type LegendProps = HTMLAttributes<HTMLLegendElement> & {
$disabled?: boolean | undefined
$hasError?: boolean | undefined
$isHidden?: boolean | undefined
$isRequired?: boolean | undefined
disabled?: boolean | undefined
hasError?: boolean | undefined
isHidden?: boolean | undefined
}
export const Legend = styled.legend.attrs<LegendProps, LegendProps>(props => ({
className: classnames('Element-Legend', props.className)
}))`
color: ${p =>
// eslint-disable-next-line no-nested-ternary
p.disabled ? p.theme.color.lightGray : p.hasError ? p.theme.color.maximumRed : p.theme.color.slateGray};
display: ${p => (p.isHidden ? 'none' : 'block')};
p.$disabled ? p.theme.color.lightGray : p.$hasError ? p.theme.color.maximumRed : p.theme.color.slateGray};
display: ${p => (p.$isHidden ? 'none' : 'block')};
font-size: 13px;
line-height: 1.3846;
margin-bottom: 4px;
Expand Down
6 changes: 3 additions & 3 deletions stories/elements/Legend.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import type { LegendProps } from '../../src'
import type { Meta } from '@storybook/react'

const args: LegendProps = {
$disabled: false,
$isHidden: false,
$isRequired: false,
children: 'A form fieldset legend',
disabled: false,
isHidden: false
children: 'A form fieldset legend'
}

/* eslint-disable sort-keys-fix/sort-keys-fix */
Expand Down

0 comments on commit ef4284a

Please sign in to comment.