source: src/components/label/styles.ts@ 5d6f37a

main
Last change on this file since 5d6f37a was 5d6f37a, checked in by Naum Shapkarovski <naumshapkarovski@…>, 7 weeks ago

add customer

  • Property mode set to 100644
File size: 2.4 KB
Line 
1// @mui
2import { alpha, Theme, styled } from '@mui/material/styles';
3import Box from '@mui/material/Box';
4//
5import { LabelColor, LabelVariant } from './types';
6
7// ----------------------------------------------------------------------
8
9export const StyledLabel = styled(Box)(({
10 theme,
11 ownerState,
12}: {
13 theme: Theme;
14 ownerState: {
15 color: LabelColor;
16 variant: LabelVariant;
17 };
18}) => {
19 const isLight = theme.palette.mode === 'light';
20
21 const filledVariant = ownerState.variant === 'filled';
22
23 const outlinedVariant = ownerState.variant === 'outlined';
24
25 const softVariant = ownerState.variant === 'soft';
26
27 const defaultStyle = {
28 ...(ownerState.color === 'default' && {
29 // FILLED
30 ...(filledVariant && {
31 color: isLight ? theme.palette.common.white : theme.palette.grey[800],
32 backgroundColor: theme.palette.text.primary,
33 }),
34 // OUTLINED
35 ...(outlinedVariant && {
36 backgroundColor: 'transparent',
37 color: theme.palette.text.primary,
38 border: `2px solid ${theme.palette.text.primary}`,
39 }),
40 // SOFT
41 ...(softVariant && {
42 color: theme.palette.text.secondary,
43 backgroundColor: alpha(theme.palette.grey[500], 0.16),
44 }),
45 }),
46 };
47
48 const colorStyle = {
49 ...(ownerState.color !== 'default' && {
50 // FILLED
51 ...(filledVariant && {
52 color: theme.palette[ownerState.color].contrastText,
53 backgroundColor: theme.palette[ownerState.color].main,
54 }),
55 // OUTLINED
56 ...(outlinedVariant && {
57 backgroundColor: 'transparent',
58 color: theme.palette[ownerState.color].main,
59 border: `2px solid ${theme.palette[ownerState.color].main}`,
60 }),
61 // SOFT
62 ...(softVariant && {
63 color: theme.palette[ownerState.color][isLight ? 'dark' : 'light'],
64 backgroundColor: alpha(theme.palette[ownerState.color].main, 0.16),
65 }),
66 }),
67 };
68
69 return {
70 height: 24,
71 minWidth: 24,
72 lineHeight: 0,
73 borderRadius: 6,
74 cursor: 'default',
75 alignItems: 'center',
76 whiteSpace: 'nowrap',
77 display: 'inline-flex',
78 justifyContent: 'center',
79 textTransform: 'capitalize',
80 padding: theme.spacing(0, 0.75),
81 fontSize: theme.typography.pxToRem(12),
82 fontWeight: theme.typography.fontWeightBold,
83 transition: theme.transitions.create('all', {
84 duration: theme.transitions.duration.shorter,
85 }),
86 ...defaultStyle,
87 ...colorStyle,
88 };
89});
Note: See TracBrowser for help on using the repository browser.