File tree Expand file tree Collapse file tree 1 file changed +36
-1
lines changed
packages/core/src/components Expand file tree Collapse file tree 1 file changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ const Surface: React.FC<React.PropsWithChildren<Props>> = ({
4848 style = { [
4949 {
5050 backgroundColor : getBackgroundColor ( ) ,
51- elevation,
51+ ... shadow ( elevation ) ,
5252 ...restStyle ,
5353 } ,
5454 ] }
@@ -58,4 +58,39 @@ const Surface: React.FC<React.PropsWithChildren<Props>> = ({
5858 ) ;
5959} ;
6060
61+ const SHADOW_COLOR = "#000" ;
62+ const SHADOW_OPACITY = 0.24 ;
63+
64+ function shadow ( elevation : number ) {
65+ if ( elevation === 0 ) {
66+ return { } ;
67+ }
68+
69+ let height , radius ;
70+ switch ( elevation ) {
71+ case 1 :
72+ height = 0.5 ;
73+ radius = 0.75 ;
74+ break ;
75+ case 2 :
76+ height = 0.75 ;
77+ radius = 1.5 ;
78+ break ;
79+ default :
80+ height = elevation - 1 ;
81+ radius = elevation ;
82+ }
83+
84+ return {
85+ shadowColor : SHADOW_COLOR ,
86+ shadowOffset : {
87+ width : 0 ,
88+ height,
89+ } ,
90+ shadowOpacity : SHADOW_OPACITY ,
91+ shadowRadius : radius ,
92+ elevation,
93+ } ;
94+ }
95+
6196export default withTheme ( Surface ) ;
You can’t perform that action at this time.
0 commit comments