Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(elements): prefix styled component props in Legend #1364

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/Banner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ const ContentWrapper = styled.div<ContentWrapperProps>`
const ButtonWrapper = styled.div`
align-self: center;
`
const HideText = styled.span<{ $level: Level }>`
const HideText = styled.span<{
$level: Level
}>`
${p =>
p.$level === Level.ERROR
? css`
Expand Down
4 changes: 3 additions & 1 deletion src/components/Dialog/Body.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import styled from 'styled-components'

export const Body = styled.div<{ $color?: string }>`
export const Body = styled.div<{
$color?: string
}>`
background-color: ${p => p.theme.color.white};
border-top-left-radius: 2px;
border-top-right-radius: 2px;
Expand Down
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
10 changes: 5 additions & 5 deletions src/fields/DateRangePicker/RangedTimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export function RangedTimePicker({ filter, minutesRange, onChange }: RangedTimeP
{filteredRangedTimeOptions.map(({ label, value }, index) => (
<Option
key={label}
$isSelected={index === selectedOptionIndex}
aria-selected={false}
className="js-ranged-time-picker-option"
isSelected={index === selectedOptionIndex}
onClick={() => onChange(value)}
role="option"
tabIndex={-1}
Expand Down Expand Up @@ -142,16 +142,16 @@ const Box = styled.div`
`

const Option = styled.div<{
isSelected: boolean
$isSelected: boolean
}>`
background-color: ${p => (p.isSelected ? p.theme.color.blueGray : 'transparent')};
color: ${p => (p.isSelected ? p.theme.color.white : p.theme.color.gunMetal)};
background-color: ${p => (p.$isSelected ? p.theme.color.blueGray : 'transparent')};
color: ${p => (p.$isSelected ? p.theme.color.white : p.theme.color.gunMetal)};
cursor: pointer;
line-height: 1;
padding: 8.5px 0 10.5px 8px;

&:hover {
background-color: ${p => (p.isSelected ? p.theme.color.blueGray : p.theme.color.blueYonder25)};
background-color: ${p => (p.$isSelected ? p.theme.color.blueGray : p.theme.color.blueYonder25)};
}

> span {
Expand Down
14 changes: 7 additions & 7 deletions src/fields/DateRangePicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ export function DateRangePicker({
</Field>

{withTime && (
<Field isTimeField>
<Field $isTimeField>
<TimeInput
ref={startTimeInputRef}
baseContainer={baseContainer ?? undefined}
Expand All @@ -516,7 +516,7 @@ export function DateRangePicker({
</Field>
)}

<Field isEndDateField>
<Field $isEndDateField>
<DateInput
ref={endDateInputRef}
baseContainer={baseContainer ?? undefined}
Expand All @@ -542,7 +542,7 @@ export function DateRangePicker({
</Field>

{withTime && (
<Field isTimeField>
<Field $isTimeField>
<TimeInput
ref={endTimeInputRef}
baseContainer={baseContainer ?? undefined}
Expand Down Expand Up @@ -604,15 +604,15 @@ const Box = styled.div<CommonFieldStyleProps>`
`

const Field = styled.span<{
isEndDateField?: boolean
isTimeField?: boolean
$isEndDateField?: boolean
$isTimeField?: boolean
}>`
font-size: inherit;
margin-left: ${p => {
if (p.isEndDateField) {
if (p.$isEndDateField) {
return '10px'
}

return p.isTimeField ? '2px' : 0
return p.$isTimeField ? '2px' : 0
}} !important;
`
4 changes: 3 additions & 1 deletion src/fields/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ const IconsContainer = styled.div<{
top: ${p => (p.$size === Size.LARGE ? '9px' : '5px')};
`

const RestyledStyledInputBox = styled(StyledInputBox)<{ $isSearchInput: boolean }>`
const RestyledStyledInputBox = styled(StyledInputBox)<{
$isSearchInput: boolean
}>`
> input,
> .rs-auto-complete > input {
padding-right: ${p => p.$isSearchInput && '64px'};
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
Loading