Skip to content

Commit 7005a7e

Browse files
committed
fix(HTL-124104): ftc attrs
1 parent cb12413 commit 7005a7e

File tree

2 files changed

+38
-23
lines changed

2 files changed

+38
-23
lines changed

packages/core/src/Button/Button.stories.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ export const Playground: ButtonStory = {
6262
},
6363
}
6464

65+
export const Attrs: ButtonStory = {
66+
render: () => (
67+
<StoryStage>
68+
<Button size='extraLarge' gv-criticalpath='true' gv-hotelid='1234'>
69+
Extra Large
70+
</Button>
71+
</StoryStage>
72+
),
73+
}
74+
6575
export const Size: ButtonStory = {
6676
render: () => (
6777
<StoryStage>

packages/core/src/Button/Button.tsx

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -317,31 +317,36 @@ function getPaddingProps({ IconLeft, IconRight, size, variation, hasChildren }:
317317
/**
318318
* Use the <Button /> component to render a primitive button. Use the `variation` prop to change the look of the button.
319319
*/
320-
const StyledButton: React.FC<StyledButtonProps> = styled.button.attrs((props) => {
321-
const {
322-
width,
323-
height,
324-
title,
325-
'aria-label': ariaLabel,
326-
borderRadius,
327-
IconLeft,
328-
IconRight,
329-
size,
330-
variation,
331-
hasChildren,
332-
} = props
320+
const StyledButton: React.FC<StyledButtonProps> = styled.button
321+
.withConfig({
322+
shouldForwardProp: (prop, defaultValidatorFn) => prop.startsWith('gv-') || defaultValidatorFn(prop),
323+
})
324+
.attrs((props) => {
325+
const {
326+
width,
327+
height,
328+
title,
329+
'aria-label': ariaLabel,
330+
borderRadius,
331+
IconLeft,
332+
IconRight,
333+
size,
334+
variation,
335+
hasChildren,
336+
} = props
333337

334-
const paddingProps = getPaddingProps({ IconLeft, IconRight, size, variation, hasChildren })
338+
const paddingProps = getPaddingProps({ IconLeft, IconRight, size, variation, hasChildren })
335339

336-
return {
337-
borderRadius,
338-
...boxShadowAttrs(props),
339-
width,
340-
height,
341-
'aria-label': ariaLabel || title,
342-
...paddingProps,
343-
}
344-
})`
340+
return {
341+
borderRadius,
342+
...boxShadowAttrs(props),
343+
width,
344+
height,
345+
'aria-label': ariaLabel || title,
346+
...props,
347+
...paddingProps,
348+
}
349+
})`
345350
${buttonStyles}
346351
347352
${(props) => compose(width, height, space, boxShadow)(props)}

0 commit comments

Comments
 (0)