Skip to content

Commit e1ad32a

Browse files
authored
refactor(components): resolve buttons' nested structure (#18840)
* refactor(components): resolve buttons' nested structure
1 parent 4d7c32b commit e1ad32a

File tree

8 files changed

+27
-50
lines changed

8 files changed

+27
-50
lines changed

components/src/atoms/buttons/AlertPrimaryButton.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import styled from 'styled-components'
22

33
import { BORDERS, COLORS } from '../../helix-design-system'
4-
import { NewAlertPrimaryBtn, styleProps } from '../../primitives'
4+
import { Btn, styleProps } from '../../primitives'
55
import { SPACING, TYPOGRAPHY } from '../../ui-style-constants'
66

7-
export const AlertPrimaryButton = styled(NewAlertPrimaryBtn)`
7+
export const AlertPrimaryButton = styled(Btn)`
8+
color: ${COLORS.white};
89
background-color: ${COLORS.red50};
910
border-radius: ${BORDERS.borderRadius8};
10-
padding-left: ${SPACING.spacing16};
11-
padding-right: ${SPACING.spacing16};
11+
padding: ${SPACING.spacing8} ${SPACING.spacing16};
1212
text-transform: ${TYPOGRAPHY.textTransformNone};
1313
box-shadow: 0 0 0;
1414
${TYPOGRAPHY.pSemiBold}

components/src/atoms/buttons/AltPrimaryButton.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import styled from 'styled-components'
22

3-
import { PrimaryButton } from '../..'
4-
import { COLORS } from '../../helix-design-system'
5-
import { styleProps } from '../../primitives'
3+
import { BORDERS, COLORS } from '../../helix-design-system'
4+
import { Btn, styleProps } from '../../primitives'
5+
import { SPACING, TYPOGRAPHY } from '../../ui-style-constants'
66

7-
export const AltPrimaryButton = styled(PrimaryButton)`
7+
export const AltPrimaryButton = styled(Btn)`
88
background-color: ${COLORS.grey30};
99
color: ${COLORS.black90};
10+
padding: ${SPACING.spacing8} ${SPACING.spacing16};
11+
border-radius: ${BORDERS.borderRadius8};
12+
box-shadow: none;
13+
font-size: ${TYPOGRAPHY.fontSizeH3};
14+
font-weight: ${TYPOGRAPHY.fontWeightSemiBold};
15+
line-height: ${TYPOGRAPHY.lineHeight20};
1016
1117
${styleProps}
1218

components/src/atoms/buttons/PrimaryButton.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import styled from 'styled-components'
22

33
import { BORDERS, COLORS } from '../../helix-design-system'
4-
import { NewPrimaryBtn, styleProps } from '../../primitives'
4+
import { Btn, styleProps } from '../../primitives'
55
import { SPACING, TYPOGRAPHY } from '../../ui-style-constants'
66

7-
export const PrimaryButton = styled(NewPrimaryBtn)`
7+
export const PrimaryButton = styled(Btn)`
8+
color: ${COLORS.white};
89
background-color: ${COLORS.blue50};
910
border-radius: ${BORDERS.borderRadius8};
1011
box-shadow: none;
11-
padding-left: ${SPACING.spacing16};
12-
padding-right: ${SPACING.spacing16};
12+
padding: ${SPACING.spacing8} ${SPACING.spacing16};
1313
line-height: ${TYPOGRAPHY.lineHeight20};
1414
text-transform: ${TYPOGRAPHY.textTransformNone};
1515
font-size: ${TYPOGRAPHY.fontSizeH3};

components/src/atoms/buttons/__tests__/AlertPrimaryButton.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('AlertPrimaryButton', () => {
2828
const button = screen.getByText('alert primary button')
2929
expect(button).toHaveStyle(`background-color: ${COLORS.red50}`)
3030
expect(button).toHaveStyle(
31-
`padding: ${SPACING.spacing8} ${SPACING.spacing16} ${SPACING.spacing8} ${SPACING.spacing16}`
31+
`padding: ${SPACING.spacing8} ${SPACING.spacing16}`
3232
)
3333
expect(button).toHaveStyle(`font-size: ${TYPOGRAPHY.fontSizeP}`)
3434
expect(button).toHaveStyle(`font-weight: ${TYPOGRAPHY.fontWeightSemiBold}`)

components/src/atoms/buttons/__tests__/AltPrimaryButton.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('AltPrimaryButton', () => {
2828
const button = screen.getByText('alt primary button')
2929
expect(button).toHaveStyle(`background-color: ${COLORS.grey30}`)
3030
expect(button).toHaveStyle(
31-
`padding: ${SPACING.spacing8} ${SPACING.spacing16} ${SPACING.spacing8} ${SPACING.spacing16}`
31+
`padding: ${SPACING.spacing8} ${SPACING.spacing16}`
3232
)
3333
expect(button).toHaveStyle(`font-size: ${TYPOGRAPHY.fontSizeH3}`)
3434
expect(button).toHaveStyle(`font-weight: ${TYPOGRAPHY.fontWeightSemiBold}`)

components/src/atoms/buttons/__tests__/PrimaryButton.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('PrimaryButton', () => {
2828
const button = screen.getByText('primary button')
2929
expect(button).toHaveStyle(`background-color: ${COLORS.blue50}`)
3030
expect(button).toHaveStyle(
31-
`padding: ${SPACING.spacing8} ${SPACING.spacing16} ${SPACING.spacing8} ${SPACING.spacing16}`
31+
`padding: ${SPACING.spacing8} ${SPACING.spacing16}`
3232
)
3333
expect(button).toHaveStyle(`font-size: ${TYPOGRAPHY.fontSizeH3}`)
3434
expect(button).toHaveStyle(`font-weight: ${TYPOGRAPHY.fontWeightSemiBold}`)

components/src/primitives/Btn.stories.tsx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Box } from './Box'
22
import {
33
LightSecondaryBtn,
4-
NewAlertPrimaryBtn,
54
NewAlertSecondaryBtn,
65
NewPrimaryBtn,
76
NewSecondaryBtn,
@@ -36,37 +35,28 @@ Secondary.args = {
3635
title: 'secondary button title',
3736
}
3837

39-
const AppPrimaryTemlate: Story<
38+
const AppPrimaryTemplate: Story<
4039
React.ComponentProps<typeof NewPrimaryBtn>
4140
> = args => <NewPrimaryBtn {...args} />
42-
export const AppPrimary = AppPrimaryTemlate.bind({})
41+
export const AppPrimary = AppPrimaryTemplate.bind({})
4342
AppPrimary.args = {
4443
children: 'Confirm and Proceed',
4544
title: 'app primary button title',
4645
}
4746

48-
const AppSecondaryTemlate: Story<
47+
const AppSecondaryTemplate: Story<
4948
React.ComponentProps<typeof NewSecondaryBtn>
5049
> = args => <NewSecondaryBtn {...args} />
51-
export const AppSecondary = AppSecondaryTemlate.bind({})
50+
export const AppSecondary = AppSecondaryTemplate.bind({})
5251
AppSecondary.args = {
5352
children: 'Confirm and Proceed',
5453
title: 'app secondary button title',
5554
}
5655

57-
const AppAlertPrimaryTemlate: Story<
58-
React.ComponentProps<typeof NewAlertPrimaryBtn>
59-
> = args => <NewAlertPrimaryBtn {...args} />
60-
export const AppAlertPrimary = AppAlertPrimaryTemlate.bind({})
61-
AppAlertPrimary.args = {
62-
children: 'Cancel',
63-
title: 'app alert primary button title',
64-
}
65-
66-
const AppAlertSecondaryTemlate: Story<
56+
const AppAlertSecondaryTemplate: Story<
6757
React.ComponentProps<typeof NewAlertSecondaryBtn>
6858
> = args => <NewAlertSecondaryBtn {...args} />
69-
export const AppAlertSecondary = AppAlertSecondaryTemlate.bind({})
59+
export const AppAlertSecondary = AppAlertSecondaryTemplate.bind({})
7060
AppAlertSecondary.args = {
7161
children: 'Cancel',
7262
title: 'app alert secondary button title',

components/src/primitives/Btn.tsx

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -190,25 +190,6 @@ export const NewSecondaryBtn = styled(SecondaryBtn)`
190190
191191
${styleProps}
192192
`
193-
/**
194-
* Red primary button variant used in app
195-
*
196-
* @component
197-
*/
198-
export const NewAlertPrimaryBtn = styled(NewPrimaryBtn)`
199-
background-color: ${Styles.C_ERROR_DARK};
200-
201-
&:hover,
202-
&:focus {
203-
background-color: ${Styles.C_ERROR_DARK};
204-
}
205-
206-
&:active {
207-
background-color: ${Styles.C_ERROR_LIGHT};
208-
}
209-
210-
${styleProps}
211-
`
212193

213194
/**
214195
* Red secondary button variant used in app

0 commit comments

Comments
 (0)