@@ -2,6 +2,7 @@ import type {DO_NOT_USE_ChonkTheme} from '@emotion/react';
22
33import type { DO_NOT_USE_ButtonProps as ButtonProps } from 'sentry/components/core/button/types' ;
44import type { StrictCSSObject } from 'sentry/utils/theme' ;
5+ import { unreachable } from 'sentry/utils/unreachable' ;
56
67// @TODO : remove Link type in the future
78type ChonkButtonType =
@@ -33,8 +34,25 @@ function chonkPriorityToType(priority: ButtonProps['priority']): ChonkButtonType
3334 }
3435}
3536
37+ function chonkElevation ( size : NonNullable < ButtonProps [ 'size' ] > ) : string {
38+ switch ( size ) {
39+ case 'md' :
40+ return '3px' ;
41+ case 'sm' :
42+ return '2px' ;
43+ case 'xs' :
44+ return '1px' ;
45+ case 'zero' :
46+ return '0px' ;
47+ default :
48+ unreachable ( size ) ;
49+ throw new Error ( `Unknown button size: ${ size } ` ) ;
50+ }
51+ }
52+
3653export function DO_NOT_USE_getChonkButtonStyles (
37- p : Pick < ButtonProps , 'size' | 'priority' | 'busy' | 'disabled' | 'borderless' > & {
54+ p : Pick < ButtonProps , 'priority' | 'busy' | 'disabled' | 'borderless' > & {
55+ size : NonNullable < ButtonProps [ 'size' ] > ;
3856 theme : DO_NOT_USE_ChonkTheme ;
3957 }
4058) : StrictCSSObject {
@@ -56,7 +74,6 @@ export function DO_NOT_USE_getChonkButtonStyles(
5674 border : 'none' ,
5775 color : getChonkButtonTheme ( type , p . theme ) . color ,
5876
59- transform : 'translateY(0px)' ,
6077 background : 'none' ,
6178
6279 height :
@@ -74,9 +91,11 @@ export function DO_NOT_USE_getChonkButtonStyles(
7491 content : '""' ,
7592 display : 'block' ,
7693 position : 'absolute' ,
77- inset : '0px' ,
78- bottom : '2px' ,
79- boxShadow : `0 3px 0 0px ${ getChonkButtonTheme ( type , p . theme ) . background } ` ,
94+ inset : '0' ,
95+ height : `calc(100% - ${ chonkElevation ( p . size ) } )` ,
96+ top : `${ chonkElevation ( p . size ) } ` ,
97+ transform : `translateY(-${ chonkElevation ( p . size ) } )` ,
98+ boxShadow : `0 ${ chonkElevation ( p . size ) } 0 0px ${ getChonkButtonTheme ( type , p . theme ) . background } ` ,
8099 background : getChonkButtonTheme ( type , p . theme ) . background ,
81100 borderRadius : 'inherit' ,
82101 } ,
@@ -89,13 +108,16 @@ export function DO_NOT_USE_getChonkButtonStyles(
89108 background : getChonkButtonTheme ( type , p . theme ) . surface ,
90109 borderRadius : 'inherit' ,
91110 border : `1px solid ${ getChonkButtonTheme ( type , p . theme ) . background } ` ,
92- transform : ' translateY(-2px)' ,
111+ transform : ` translateY(-${ chonkElevation ( p . size ) } )` ,
93112 transition : 'transform 0.1s ease-in-out' ,
94113 } ,
95114
96115 '&:focus-visible' : {
116+ outline : 'none' ,
117+
97118 '&::after' : {
98- ...p . theme . focusRing ,
119+ border : `1px solid ${ p . theme . focusBorder } ` ,
120+ boxShadow : `0 0 0 1px ${ p . theme . focusBorder } ` ,
99121 } ,
100122 } ,
101123
@@ -111,18 +133,18 @@ export function DO_NOT_USE_getChonkButtonStyles(
111133 overflow : 'hidden' ,
112134
113135 whiteSpace : 'nowrap' ,
114- transform : ' translateY(-2px)' ,
136+ transform : ` translateY(-${ chonkElevation ( p . size ) } )` ,
115137 transition : 'transform 0.06s ease-in-out' ,
116138 } ,
117139
118140 '&:hover' : {
119141 color : p . disabled || p . busy ? undefined : getChonkButtonTheme ( type , p . theme ) . color ,
120142
121143 '&::after' : {
122- transform : `translateY(-3px )` ,
144+ transform : `translateY(calc(- ${ chonkElevation ( p . size ) } - 2px) )` ,
123145 } ,
124146 '> span:last-child' : {
125- transform : `translateY(-3px )` ,
147+ transform : `translateY(calc(- ${ chonkElevation ( p . size ) } - 2px) )` ,
126148 } ,
127149 } ,
128150
@@ -139,9 +161,6 @@ export function DO_NOT_USE_getChonkButtonStyles(
139161 '&::after' : {
140162 transform : 'translateY(0px)' ,
141163 } ,
142- '&::before' : {
143- transform : 'translateY(0px)' ,
144- } ,
145164 '> span:last-child' : {
146165 transform : 'translateY(0px)' ,
147166 } ,
0 commit comments