-
-
Notifications
You must be signed in to change notification settings - Fork 625
Expand file tree
/
Copy pathbase.css
More file actions
161 lines (145 loc) · 6.11 KB
/
base.css
File metadata and controls
161 lines (145 loc) · 6.11 KB
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
157
158
159
160
161
/* VARIABLES
=================================================== */
:root {
/* For animating height */
interpolate-size: allow-keywords;
--focus-outline-width: 2px;
/* Here we typically need a negative outline-offset because of the inner shadow on inputs */
--focus-outline-offset: -1px;
--focus-within-outline-offset: 0px;
--focus-outline-color: var(--theme-color-focus-outline, var(--color-blue-400));
--focus-outline-style: solid;
--danger-outline-color: oklch(from var(--theme-color-danger) l c h / 0.5);
/* The outline-offset value used for buttons */
--outline-offset-button: 6px;
--z-index-below: -1;
--z-index-above: 1;
--z-index-portal: 2;
--z-index-draggable: 3;
--z-index-modal: 4;
--z-index-max: 5;
/* Used for entry animations */
--starting-style-transition-duration: 0.125s;
--starting-style-sibling-delay: 0.01s;
}
/* FOCUS STATES
=================================================== */
/* Use a base layer where we don't need the specificity */
@layer base {
/* Explicitly show focus without needing to tab */
.show-focus:focus,
/* Explicitly show focus without needing to tab for buttons inside modals, e.g. Assets > cancel button on delete modal */
[data-dismissable-layer] button:focus,
/* and then a global selector for focus-visible everywhere else (except where the focus-within class will handle the focus outline target instead). Use a direct descendant here so we don't affect things like the focus state of Bard field > Replicator > then another Bard field. */
:not([class*='focus-within'] > *) {
:focus-visible& {
outline-width: var(--focus-outline-width);
outline-offset: var(--focus-outline-offset);
outline-color: var(--focus-outline-color, currentColor);
outline-style: var(--focus-outline-style, solid);
border-radius: inherit;
}
}
a {
cursor: pointer;
}
::placeholder {
@apply text-gray-500;
}
:where(.dark, .dark *)::placeholder {
@apply text-gray-400;
}
[type="checkbox"] {
/* To effectively hide border radius clash with focus state */
--focus-outline-offset: -1.85px;
}
}
/* Use a utility layer only when we need higher specificity */
@layer utilities {
/* When we have a focus state within a focus state, only the inner-most focused container should _have_ focus. e.g. if we're focusing on a Bard field within a Bard field, only the inner Bard field should receive the focus outline. */
[class*="focus-within"]:has([class*="focus-within"]:focus-within) {
outline: none;
}
[data-ui-dropdown-item] {
&:focus-visible {
outline-width: var(--focus-outline-width);
outline-offset: var(--focus-outline-offset);
outline-color: var(--focus-outline-color, currentColor);
outline-style: var(--focus-outline-style, solid);
}
}
/* e.g. >> /cp/collections, when you tab to the title, and /cp/collections/pages when tabbing through the tree text. Avoid elements where border-radius has already been set, e.g. "Create Entry" button */
.main-content a:not([class*="rounded"]),
/* e.g. >> /cp/collections/pages, tabbing through the home icon. Be careful not to carpet bomb this e.g. don't want to affect Bard buttons. */
.page-tree .v-popper--has-tooltip {
&:focus-visible {
--focus-outline-offset: 4px;
@apply rounded-xs;
}
}
/* Fix "flicker" the transition causes when tabbing to disclosure e.g. >> /cp/collections/pages */
button:focus-visible {
transition: unset;
}
.group\/button button:focus {
/* Pull the focus state above any adjacent buttons e.g. >> /cp/collections/articles/entries - save button alongside the dropdown arrow */
z-index: var(--z-index-above);
}
}
/* DESTRUCTIVE STATES
=================================================== */
@layer utilities {
/* Destructive buttons */
[data-destructive]:not([data-ui-badge] *) {
--focus-outline-color: var(--danger-outline-color);
--focus-outline-width: 1px;
&:hover,
&:hover::before,
&:focus {
/* Delete states - use outline state instead so we don't have to worry about overriding borders, or adding borders to pseudo elements */
outline: var(--focus-outline-width) var(--focus-outline-style) var(--focus-outline-color);
outline-offset: var(--focus-outline-offset);
background: var(--color-danger-bg);
svg {
color: var(--color-danger);
/* Need !important to override dark mode */
opacity: 1!important;
}
}
}
/* DESTRUCTIVE STATES / BADGES
=================================================== */
/* When a badge "x" is hovered, the whole badge lights up red. */
[data-ui-badge]:has([data-destructive]:is(:hover, :focus)) {
--focus-outline-color: var(--danger-outline-color);
--focus-outline-width: 1px;
background: var(--color-danger-bg);
outline: var(--focus-outline-width) var(--focus-outline-style) var(--focus-outline-color);
outline-offset: var(--focus-outline-offset);
&, button {
color: var(--color-danger);
}
/* Cancel the outline on the actual button since we're highlighting the entire badge */
button {
outline: none;
}
}
}
/* Prevent tailwind typography from adding backticks around code elements */
@utility prose {
code {
&::before,
&::after {
content: none;
}
}
}
code:not(pre *) {
/* Take the UI accent for code color/background. Use relative colors to 1) Make sure the text color is not too bright and 2) Create a light background */
color: hsl(from var(--theme-color-ui-accent-bg) h s 30);
background: hsl(from var(--theme-color-ui-accent-bg) h s l / 0.08);
&:where(.dark, .dark *) {
color: hsl(from var(--theme-color-ui-accent-bg) h s 90);
background: hsl(from var(--theme-color-ui-accent-bg) h s 10 / 0.5);
}
}