Skip to content

Commit 95b0d1a

Browse files
authored
fix(HTL-124104): ftc attrs (#1563)
1 parent cb12413 commit 95b0d1a

File tree

7 files changed

+58
-33
lines changed

7 files changed

+58
-33
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "pcln-design-system",
5+
"comment": "add gv- attributes to Button",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "pcln-design-system"
10+
}

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)}

packages/core/src/FloatingActionButton/__snapshots__/FloatingActionButton.spec.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ exports[`FloatingActionButton it renders 1`] = `
9797
class="c1"
9898
>
9999
<button
100-
class="c2 c3"
100+
class="c2 c3 sc-gsFSXq c3"
101101
color="primary"
102102
>
103103
<div

packages/core/src/IconButton/__snapshots__/IconButton.spec.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ exports[`IconButton renders without props 1`] = `
9595
}
9696
9797
<button
98-
className="c0 c1"
98+
className="c0 c1 sc-dcJsrY c1"
9999
color="primary"
100100
size="medium"
101101
>

packages/core/src/Step/__snapshots__/Step.spec.tsx.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ exports[`Step should handle onClick 1`] = `
9090
class="c0"
9191
>
9292
<button
93-
class="c1 c2"
93+
class="c1 c2 sc-imWYAI c2"
9494
color="primary"
9595
data-testid="Step"
9696
>
@@ -214,7 +214,7 @@ exports[`Step should render a completed step correctly 1`] = `
214214
class="c0"
215215
>
216216
<button
217-
class="c1 c2"
217+
class="c1 c2 sc-imWYAI c2"
218218
color="primary"
219219
data-testid="Step"
220220
>
@@ -357,7 +357,7 @@ exports[`Step should render a step that is "active" and "completed" correctly 1`
357357
class="c0"
358358
>
359359
<button
360-
class="c1 c2"
360+
class="c1 c2 sc-imWYAI c2"
361361
color="primary"
362362
data-testid="Step"
363363
>
@@ -486,7 +486,7 @@ exports[`Step should render an active step correctly 1`] = `
486486
class="c0"
487487
>
488488
<button
489-
class="c1 c2"
489+
class="c1 c2 sc-imWYAI c2"
490490
color="primary"
491491
data-testid="Step"
492492
>
@@ -596,7 +596,7 @@ exports[`Step should render correctly with no props without throwing 1`] = `
596596
class="c0"
597597
>
598598
<button
599-
class="c1 c2"
599+
class="c1 c2 sc-imWYAI c2"
600600
color="primary"
601601
>
602602
<div

packages/core/src/Stepper/__snapshots__/Stepper.spec.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ exports[`Stepper renders with children 1`] = `
114114
className="c0 c1"
115115
>
116116
<button
117-
className="c2 c3"
117+
className="c2 c3 sc-kAyceB c3"
118118
color="primary"
119119
size="medium"
120120
>
@@ -150,7 +150,7 @@ exports[`Stepper renders with children 1`] = `
150150
</div>
151151
</button>
152152
<button
153-
className="c2 c3"
153+
className="c2 c3 sc-kAyceB c3"
154154
color="primary"
155155
size="medium"
156156
>
@@ -168,7 +168,7 @@ exports[`Stepper renders with children 1`] = `
168168
</div>
169169
</button>
170170
<button
171-
className="c2 c3"
171+
className="c2 c3 sc-kAyceB c3"
172172
color="primary"
173173
size="medium"
174174
>

0 commit comments

Comments
 (0)