1 | // @mui
|
---|
2 | import { alpha, Theme } from '@mui/material/styles';
|
---|
3 | import { dividerClasses } from '@mui/material/Divider';
|
---|
4 | import { checkboxClasses } from '@mui/material/Checkbox';
|
---|
5 | import { menuItemClasses } from '@mui/material/MenuItem';
|
---|
6 | import { autocompleteClasses } from '@mui/material/Autocomplete';
|
---|
7 |
|
---|
8 | // ----------------------------------------------------------------------
|
---|
9 |
|
---|
10 | export const paper = ({
|
---|
11 | theme,
|
---|
12 | bgcolor,
|
---|
13 | dropdown,
|
---|
14 | }: {
|
---|
15 | theme: Theme;
|
---|
16 | bgcolor?: string;
|
---|
17 | dropdown?: boolean;
|
---|
18 | }) => ({
|
---|
19 | ...bgBlur({
|
---|
20 | blur: 20,
|
---|
21 | opacity: 0.9,
|
---|
22 | color: theme.palette.background.paper,
|
---|
23 | ...(!!bgcolor && {
|
---|
24 | color: bgcolor,
|
---|
25 | }),
|
---|
26 | }),
|
---|
27 | backgroundImage: 'url(/assets/cyan-blur.png), url(/assets/red-blur.png)',
|
---|
28 | backgroundRepeat: 'no-repeat, no-repeat',
|
---|
29 | backgroundPosition: 'top right, left bottom',
|
---|
30 | backgroundSize: '50%, 50%',
|
---|
31 | ...(theme.direction === 'rtl' && {
|
---|
32 | backgroundPosition: 'top left, right bottom',
|
---|
33 | }),
|
---|
34 | ...(dropdown && {
|
---|
35 | padding: theme.spacing(0.5),
|
---|
36 | boxShadow: theme.customShadows.dropdown,
|
---|
37 | borderRadius: theme.shape.borderRadius * 1.25,
|
---|
38 | }),
|
---|
39 | });
|
---|
40 |
|
---|
41 | // ----------------------------------------------------------------------
|
---|
42 |
|
---|
43 | export const menuItem = (theme: Theme) => ({
|
---|
44 | ...theme.typography.body2,
|
---|
45 | padding: theme.spacing(0.75, 1),
|
---|
46 | borderRadius: theme.shape.borderRadius * 0.75,
|
---|
47 | '&:not(:last-of-type)': {
|
---|
48 | marginBottom: 4,
|
---|
49 | },
|
---|
50 | [`&.${menuItemClasses.selected}`]: {
|
---|
51 | fontWeight: theme.typography.fontWeightSemiBold,
|
---|
52 | backgroundColor: theme.palette.action.selected,
|
---|
53 | '&:hover': {
|
---|
54 | backgroundColor: theme.palette.action.hover,
|
---|
55 | },
|
---|
56 | },
|
---|
57 | [`& .${checkboxClasses.root}`]: {
|
---|
58 | padding: theme.spacing(0.5),
|
---|
59 | marginLeft: theme.spacing(-0.5),
|
---|
60 | marginRight: theme.spacing(0.5),
|
---|
61 | },
|
---|
62 | [`&.${autocompleteClasses.option}[aria-selected="true"]`]: {
|
---|
63 | backgroundColor: theme.palette.action.selected,
|
---|
64 | '&:hover': {
|
---|
65 | backgroundColor: theme.palette.action.hover,
|
---|
66 | },
|
---|
67 | },
|
---|
68 | [`&+.${dividerClasses.root}`]: {
|
---|
69 | margin: theme.spacing(0.5, 0),
|
---|
70 | },
|
---|
71 | });
|
---|
72 |
|
---|
73 | // ----------------------------------------------------------------------
|
---|
74 |
|
---|
75 | type BgBlurProps = {
|
---|
76 | blur?: number;
|
---|
77 | opacity?: number;
|
---|
78 | color?: string;
|
---|
79 | imgUrl?: string;
|
---|
80 | };
|
---|
81 |
|
---|
82 | export function bgBlur(props?: BgBlurProps) {
|
---|
83 | const color = props?.color || '#000000';
|
---|
84 | const blur = props?.blur || 6;
|
---|
85 | const opacity = props?.opacity || 0.8;
|
---|
86 | const imgUrl = props?.imgUrl;
|
---|
87 |
|
---|
88 | if (imgUrl) {
|
---|
89 | return {
|
---|
90 | position: 'relative',
|
---|
91 | backgroundImage: `url(${imgUrl})`,
|
---|
92 | '&:before': {
|
---|
93 | position: 'absolute',
|
---|
94 | top: 0,
|
---|
95 | left: 0,
|
---|
96 | zIndex: 9,
|
---|
97 | content: '""',
|
---|
98 | width: '100%',
|
---|
99 | height: '100%',
|
---|
100 | backdropFilter: `blur(${blur}px)`,
|
---|
101 | WebkitBackdropFilter: `blur(${blur}px)`,
|
---|
102 | backgroundColor: alpha(color, opacity),
|
---|
103 | },
|
---|
104 | } as const;
|
---|
105 | }
|
---|
106 |
|
---|
107 | return {
|
---|
108 | backdropFilter: `blur(${blur}px)`,
|
---|
109 | WebkitBackdropFilter: `blur(${blur}px)`,
|
---|
110 | backgroundColor: alpha(color, opacity),
|
---|
111 | };
|
---|
112 | }
|
---|
113 |
|
---|
114 | // ----------------------------------------------------------------------
|
---|
115 |
|
---|
116 | type BgGradientProps = {
|
---|
117 | direction?: string;
|
---|
118 | color?: string;
|
---|
119 | startColor?: string;
|
---|
120 | endColor?: string;
|
---|
121 | imgUrl?: string;
|
---|
122 | };
|
---|
123 |
|
---|
124 | export function bgGradient(props?: BgGradientProps) {
|
---|
125 | const direction = props?.direction || 'to bottom';
|
---|
126 | const startColor = props?.startColor;
|
---|
127 | const endColor = props?.endColor;
|
---|
128 | const imgUrl = props?.imgUrl;
|
---|
129 | const color = props?.color;
|
---|
130 |
|
---|
131 | if (imgUrl) {
|
---|
132 | return {
|
---|
133 | background: `linear-gradient(${direction}, ${startColor || color}, ${
|
---|
134 | endColor || color
|
---|
135 | }), url(${imgUrl})`,
|
---|
136 | backgroundSize: 'cover',
|
---|
137 | backgroundRepeat: 'no-repeat',
|
---|
138 | backgroundPosition: 'center center',
|
---|
139 | };
|
---|
140 | }
|
---|
141 |
|
---|
142 | return {
|
---|
143 | background: `linear-gradient(${direction}, ${startColor}, ${endColor})`,
|
---|
144 | };
|
---|
145 | }
|
---|
146 |
|
---|
147 | // ----------------------------------------------------------------------
|
---|
148 |
|
---|
149 | export function textGradient(value: string) {
|
---|
150 | return {
|
---|
151 | background: `-webkit-linear-gradient(${value})`,
|
---|
152 | WebkitBackgroundClip: 'text',
|
---|
153 | WebkitTextFillColor: 'transparent',
|
---|
154 | };
|
---|
155 | }
|
---|
156 |
|
---|
157 | // ----------------------------------------------------------------------
|
---|
158 |
|
---|
159 | export const hideScroll = {
|
---|
160 | x: {
|
---|
161 | msOverflowStyle: 'none',
|
---|
162 | scrollbarWidth: 'none',
|
---|
163 | overflowX: 'scroll',
|
---|
164 | '&::-webkit-scrollbar': {
|
---|
165 | display: 'none',
|
---|
166 | },
|
---|
167 | },
|
---|
168 | y: {
|
---|
169 | msOverflowStyle: 'none',
|
---|
170 | scrollbarWidth: 'none',
|
---|
171 | overflowY: 'scroll',
|
---|
172 | '&::-webkit-scrollbar': {
|
---|
173 | display: 'none',
|
---|
174 | },
|
---|
175 | },
|
---|
176 | } as const;
|
---|