Skip to content

Commit 5488b39

Browse files
committed
button: use css for string literals
1 parent 368ae96 commit 5488b39

File tree

2 files changed

+45
-21
lines changed

2 files changed

+45
-21
lines changed

static/app/components/core/button/index.chonk.tsx

Whitespace-only changes.

static/app/components/core/button/index.tsx

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -374,12 +374,12 @@ const getBoxShadow = ({
374374
: '';
375375
const dropShadow = size === 'xs' ? theme.dropShadowLight : theme.dropShadowMedium;
376376

377-
return `
378-
box-shadow: ${translucentBorderString} ${dropShadow};
379-
&:active {
380-
box-shadow: ${translucentBorderString} inset ${dropShadow};
381-
}
382-
`;
377+
return css`
378+
box-shadow: ${translucentBorderString} ${dropShadow};
379+
&:active {
380+
box-shadow: ${translucentBorderString} inset ${dropShadow};
381+
}
382+
`;
383383
};
384384

385385
const getColors = ({
@@ -398,18 +398,22 @@ const getColors = ({
398398
switch (priority) {
399399
case 'primary':
400400
case 'danger':
401-
return `
401+
return css`
402402
border-color: ${focusBorder};
403-
box-shadow: ${focusBorder} 0 0 0 1px, ${focusShadow} 0 0 0 4px;`;
403+
box-shadow:
404+
${focusBorder} 0 0 0 1px,
405+
${focusShadow} 0 0 0 4px;
406+
`;
404407
default:
405408
if (translucentBorder) {
406409
return `
407410
border-color: ${focusBorder};
408411
box-shadow: ${focusBorder} 0 0 0 2px;`;
409412
}
410-
return `
413+
return css`
411414
border-color: ${focusBorder};
412-
box-shadow: ${focusBorder} 0 0 0 1px;`;
415+
box-shadow: ${focusBorder} 0 0 0 1px;
416+
`;
413417
}
414418
};
415419

@@ -420,9 +424,13 @@ const getColors = ({
420424
return `background-color: ${background};`;
421425
default:
422426
if (borderless) {
423-
return `background-color: transparent;`;
427+
return css`
428+
background-color: transparent;
429+
`;
424430
}
425-
return `background-color: ${background};`;
431+
return css`
432+
background-color: ${background};
433+
`;
426434
}
427435
};
428436

@@ -432,17 +440,20 @@ const getColors = ({
432440
433441
border: 1px solid ${borderless || priority === 'link' ? 'transparent' : border};
434442
435-
${translucentBorder && `border-width: 0;`}
443+
${translucentBorder &&
444+
css`
445+
border-width: 0;
446+
`}
436447
437448
&:hover {
438449
color: ${color};
439450
}
440451
441452
${size !== 'zero' &&
442-
`
453+
css`
443454
&:hover,
444455
&:active,
445-
&[aria-expanded="true"] {
456+
&[aria-expanded='true'] {
446457
color: ${colorActive || color};
447458
border-color: ${borderless || priority === 'link' ? 'transparent' : borderActive};
448459
}
@@ -547,9 +558,6 @@ export const StyledButton = styled(
547558
border-radius: ${p => p.theme.borderRadius};
548559
text-transform: none;
549560
font-weight: ${p => p.theme.fontWeightBold};
550-
${getColors};
551-
${getSizeStyles};
552-
${getBoxShadow};
553561
cursor: ${p => (p.disabled ? 'not-allowed' : 'pointer')};
554562
opacity: ${p => (p.busy || p.disabled) && '0.65'};
555563
transition:
@@ -559,12 +567,28 @@ export const StyledButton = styled(
559567
560568
${p =>
561569
p.priority === 'link' &&
562-
`font-size: inherit; font-weight: inherit; padding: 0; height: auto; min-height: auto;`}
563-
${p => p.size === 'zero' && `height: auto; min-height: auto; padding: ${space(0.25)};`}
570+
css`
571+
font-size: inherit;
572+
font-weight: inherit;
573+
padding: 0;
574+
height: auto;
575+
min-height: auto;
576+
`}
577+
${p =>
578+
p.size === 'zero' &&
579+
css`
580+
height: auto;
581+
min-height: auto;
582+
padding: ${space(0.25)};
583+
`}
564584
565-
&:focus {
585+
&:focus {
566586
outline: none;
567587
}
588+
589+
${getColors};
590+
${getSizeStyles};
591+
${getBoxShadow};
568592
`;
569593

570594
const buttonLabelPropKeys = ['size', 'borderless'];

0 commit comments

Comments
 (0)