-
Notifications
You must be signed in to change notification settings - Fork 839
/
Copy pathstep_number.styles.ts
156 lines (147 loc) Β· 4.61 KB
/
step_number.styles.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { css } from '@emotion/react';
import {
mathWithUnits,
logicalCSS,
euiFontSizeFromScale,
euiCanAnimate,
euiAnimScale,
} from '../../global_styling';
import { UseEuiTheme, makeHighContrastColor } from '../../services';
import { euiStepVariables } from './step.styles';
import { euiButtonFillColor } from '../../themes/amsterdam/global_styling/mixins';
export const euiStepNumberStyles = (euiThemeContext: UseEuiTheme) => {
const { euiTheme } = euiThemeContext;
const euiStep = euiStepVariables(euiTheme);
const createStepsNumber = (size: string, fontSize: string) => {
return `
display: inline-block;
line-height: ${size};
border-radius: ${size};
${logicalCSS('width', size)};
${logicalCSS('height', size)};
text-align: center;
color: ${euiTheme.colors.emptyShade};
background-color: ${euiTheme.colors.primary};
font-size: ${fontSize};
font-weight: ${euiTheme.font.weight.medium};
`;
};
return {
euiStepNumber: css`
flex-shrink: 0;
`,
// sizes
m: css`
${createStepsNumber(
euiStep.numberSize,
euiFontSizeFromScale('s', euiTheme)
)}
`,
s: css`
${createStepsNumber(
euiStep.numberSize,
euiFontSizeFromScale('s', euiTheme)
)}
`,
xs: css`
${createStepsNumber(
euiStep.numberXSSize,
euiFontSizeFromScale('xs', euiTheme)
)}
`,
// status
incomplete: css`
background-color: transparent;
color: ${euiTheme.colors.text};
border: ${euiTheme.border.thick};
`,
disabled: css`
background-color: ${euiButtonFillColor(euiThemeContext, 'disabled')
.backgroundColor};
color: ${makeHighContrastColor(euiTheme.colors.disabledText)(
euiButtonFillColor(euiThemeContext, 'disabled').backgroundColor
)};
`,
loading: css`
background: transparent;
`,
warning: css`
color: ${euiButtonFillColor(euiThemeContext, 'warning').color};
background-color: ${euiButtonFillColor(euiThemeContext, 'warning')
.backgroundColor};
${euiCanAnimate} {
animation: ${euiAnimScale} ${euiTheme.animation.fast}
${euiTheme.animation.bounce};
}
`,
danger: css`
color: ${euiButtonFillColor(euiThemeContext, 'danger').color};
background-color: ${euiButtonFillColor(euiThemeContext, 'danger')
.backgroundColor};
${euiCanAnimate} {
animation: ${euiAnimScale} ${euiTheme.animation.fast}
${euiTheme.animation.bounce};
}
`,
complete: css`
color: ${euiButtonFillColor(euiThemeContext, 'success').color};
background-color: ${euiButtonFillColor(euiThemeContext, 'success')
.backgroundColor};
${euiCanAnimate} {
animation: ${euiAnimScale} ${euiTheme.animation.fast}
${euiTheme.animation.bounce};
}
`,
current: css`
border: 2px solid ${euiTheme.colors.body};
box-shadow: 0 0 0 2px ${euiTheme.colors.primary};
.euiStepNumber__number {
/* Transform the step number so it appears in the center of the step circle */
display: inline-block;
transform: translateY(-2px);
}
`,
};
};
export const euiStepNumberContentStyles = ({ euiTheme }: UseEuiTheme) => {
return {
// Statuses with icon content
euiStepNumber__icon: css`
vertical-align: middle;
position: relative;
inset-block-start: -${euiTheme.border.width.thin};
`,
complete: css`
/* Thicken the checkmark by adding a slight stroke */
stroke: currentColor;
stroke-width: ${mathWithUnits(euiTheme.border.width.thin, (x) => x / 2)};
`,
danger: css`
/* Thicken the cross by adding a slight stroke */
stroke: currentColor;
stroke-width: ${mathWithUnits(euiTheme.border.width.thin, (x) => x / 2)};
`,
warning: css`
/* Slight extra visual offset */
inset-block-start: -${euiTheme.border.width.thick};
`,
// Statuses with number content
euiStepNumber__number: css``,
incomplete: css`
/* Adjusts position because of thicker border */
display: unset;
position: relative;
inset-block-start: -${euiTheme.border.width.thick};
`,
loading: css``,
disabled: css``,
current: css``,
};
};