Skip to content

Commit bcf25f0

Browse files
authored
button: add transparent button to legacy theme (#92025)
The current theme does not support a transparent button, however our UI has many instances of such buttons, which has resulted in plenty of styled decl that override this. ```tsx styled(Button)` border: none; box-shadow: none; ` ``` This change allows us to remove the styled declarations while remaining future compat with button variants.
1 parent 27067a1 commit bcf25f0

File tree

6 files changed

+15
-7
lines changed

6 files changed

+15
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default storyBook('Button', (story, APIReference) => {
1515
const theme = useTheme();
1616
const variants = theme.isChonk
1717
? ['default', 'transparent', 'primary', 'warning', 'danger', 'link']
18-
: ['default', 'primary', 'link', 'danger'];
18+
: ['default', 'transparent', 'primary', 'link', 'danger'];
1919

2020
const propMatrix: PropMatrix<ButtonProps> = {
2121
children: ['Delete', undefined],

static/app/components/core/button/linkButton.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default storyBook('LinkButton', (story, APIReference) => {
1515
const theme = useTheme();
1616
const variants = theme.isChonk
1717
? ['default', 'transparent', 'primary', 'warning', 'danger', 'link']
18-
: ['default', 'primary', 'link', 'danger'];
18+
: ['default', 'transparent', 'primary', 'link', 'danger'];
1919

2020
const propMatrix: PropMatrix<LinkButtonProps> = {
2121
children: ['Delete', undefined],

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ function chonkPriorityToType(priority: ButtonProps['priority']): ChonkButtonType
2323
// forward it so that we can write the stories for it
2424
case 'warning':
2525
return 'warning';
26-
// @ts-expect-error the previous button did not have this variant, but we still want to
27-
// forward it so that we can write the stories for it
2826
case 'transparent':
2927
return 'transparent';
3028
case 'link':

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export interface DO_NOT_USE_CommonButtonProps {
3838
* contextually the primary action, `danger` if the button will do something
3939
* destructive, `link` for visual similarity to a link.
4040
*/
41-
priority?: 'default' | 'primary' | 'danger' | 'link';
41+
priority?: 'default' | 'primary' | 'danger' | 'link' | 'transparent';
4242
/**
4343
* The size of the button
4444
*/

static/app/utils/theme/theme.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,17 @@ export const generateButtonTheme = (colors: Colors, alias: Aliases): ButtonColor
577577
focusBorder: 'transparent',
578578
focusShadow: 'transparent',
579579
},
580+
transparent: {
581+
color: alias.textColor,
582+
colorActive: alias.textColor,
583+
background: 'transparent',
584+
backgroundActive: 'transparent',
585+
border: 'transparent',
586+
borderActive: 'transparent',
587+
borderTranslucent: 'transparent',
588+
focusBorder: 'transparent',
589+
focusShadow: 'transparent',
590+
},
580591
});
581592

582593
export const generateAlertTheme = (colors: Colors, alias: Aliases): AlertColors => ({
@@ -955,7 +966,7 @@ type Level = 'sample' | 'info' | 'warning' | 'error' | 'fatal' | 'default' | 'un
955966
type LevelColors = Record<Level, string>;
956967

957968
// @TODO(jonasbadalic): Disabled is not a button variant, it's a state
958-
type Button = 'default' | 'primary' | 'danger' | 'link' | 'disabled';
969+
type Button = 'default' | 'primary' | 'danger' | 'link' | 'disabled' | 'transparent';
959970
type ButtonColors = Record<
960971
Button,
961972
{

static/app/views/performance/newTraceDetails/traceDrawer/traceDrawer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,6 @@ function TabPinButton(props: {
706706
data-test-id="trace-drawer-tab-pin-button"
707707
size="zero"
708708
onClick={props.onClick}
709-
// @ts-expect-error transparent is not supported in legacy button
710709
priority={theme.isChonk ? 'transparent' : 'default'}
711710
aria-label={props.pinned ? t('Unpin Tab') : t('Pin Tab')}
712711
icon={<StyledIconPin size="xs" isSolid={props.pinned} />}

0 commit comments

Comments
 (0)