Skip to content

Commit 3bd06e6

Browse files
committed
Remove unused CSS variables from Social Highlighter, refactor hard-coded colors in Social Highlighter and Embed to use theme variables
1 parent fdc6b2d commit 3bd06e6

2 files changed

Lines changed: 34 additions & 50 deletions

File tree

  • src

‎src/components/Social/Highlighter/index.css‎

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,16 @@
11
mark {
2-
background-color: yellow;
3-
}
4-
5-
share-highlight {
6-
/* default state */
7-
--share-highlight-text-color: inherit;
8-
--share-highlight-bg-color: hsl(180deg 40% 85%);
9-
10-
/* hover/focus state */
11-
--share-highlight-text-color-active: inherit;
12-
--share-highlight-bg-color-active: hsl(180deg 40% 75%);
13-
14-
/* tooltip */
15-
--share-highlight-tooltip-text-color: hsl(0deg 0% 100%);
16-
--share-highlight-tooltip-bg-color: hsl(0deg 0% 0%);
2+
background-color: var(--color-warning-inverse);
173
}
184

195
:where(highlighter-element) {
206
cursor: pointer;
217
display: inline-block;
228
position: relative;
23-
24-
--highlight-bg: #bfdbfe;
25-
--highlight-bg-hover: #93c5fd;
26-
--highlight-text: inherit;
27-
--dialog-bg: #fff;
28-
--dialog-shadow: 0 10px 15px -3px rgb(0 0 0 / 10%), 0 4px 6px -4px rgb(0 0 0 / 10%);
29-
--button-hover: #f3f4f6;
309
}
3110

3211
:where(highlighter-element):hover,
3312
:where(highlighter-element):focus-within {
34-
outline: 2px solid var(--highlight-bg-hover);
13+
outline: 2px solid var(--color-blue-300);
3514
outline-offset: 2px;
3615
}
3716

@@ -54,23 +33,22 @@ share-highlight {
5433
}
5534

5635
:where(highlighter-element) .highlighter__content {
57-
background-color: var(--highlight-bg);
36+
background-color: var(--color-content-inverse-active);
5837
border-radius: 0.25rem;
59-
color: var(--highlight-text);
38+
color: inherit;
6039
padding: 0.125rem 0.25rem;
6140
transition: background-color 0.2s ease;
6241
}
6342

6443
:where(highlighter-element):hover .highlighter__content,
6544
:where(highlighter-element):focus-within .highlighter__content {
66-
background-color: var(--highlight-bg-hover);
45+
background-color: var(--color-blue-300);
6746
}
6847

6948
:where(highlighter-element) .share-dialog {
70-
background-color: var(--dialog-bg);
49+
background-color: var(--color-white);
7150
border-radius: 0.5rem;
7251
bottom: calc(100% + 0.75rem);
73-
box-shadow: var(--dialog-shadow);
7452
display: none;
7553
left: 50%;
7654
padding: 0.5rem;
@@ -105,7 +83,7 @@ share-highlight {
10583
}
10684

10785
:where(highlighter-element) .share-button:hover {
108-
background-color: var(--button-hover);
86+
background-color: var(--color-page-base);
10987
transform: translateY(-1px);
11088
}
11189

@@ -114,7 +92,7 @@ share-highlight {
11492
}
11593

11694
:where(highlighter-element) .share-button:focus-visible {
117-
outline: 2px solid #3b82f6;
95+
outline: 2px solid var(--color-blue-600);
11896
outline-offset: 2px;
11997
}
12098

@@ -125,15 +103,15 @@ share-highlight {
125103
}
126104

127105
:where(highlighter-element) .copy-button {
128-
border-left: 1px solid #e5e7eb;
106+
border-left: 1px solid var(--color-page-base-offset);
129107
margin-left: 0.25rem;
130108
padding-left: 0.75rem;
131109
}
132110

133111
:where(highlighter-element) .share-dialog__arrow {
134112
border-left: 0.5rem solid transparent;
135113
border-right: 0.5rem solid transparent;
136-
border-top: 0.5rem solid var(--dialog-bg);
114+
border-top: 0.5rem solid var(--color-white);
137115
bottom: -0.375rem;
138116
height: 0;
139117
left: 50%;
@@ -143,10 +121,29 @@ share-highlight {
143121
}
144122

145123
@media (prefers-color-scheme: dark) {
146-
:where(highlighter-element) {
147-
--highlight-bg: #1e40af;
148-
--highlight-bg-hover: #1e3a8a;
149-
--dialog-bg: #1f2937;
150-
--button-hover: #374151;
124+
:where(highlighter-element):hover,
125+
:where(highlighter-element):focus-within {
126+
outline-color: var(--color-blue-900);
127+
}
128+
129+
:where(highlighter-element) .highlighter__content {
130+
background-color: var(--color-blue-800);
131+
}
132+
133+
:where(highlighter-element):hover .highlighter__content,
134+
:where(highlighter-element):focus-within .highlighter__content {
135+
background-color: var(--color-blue-900);
136+
}
137+
138+
:where(highlighter-element) .share-dialog {
139+
background-color: var(--color-gray-800);
140+
}
141+
142+
:where(highlighter-element) .share-button:hover {
143+
background-color: var(--color-gray-700);
144+
}
145+
146+
:where(highlighter-element) .share-dialog__arrow {
147+
border-top-color: var(--color-gray-800);
151148
}
152149
}

‎src/lib/markdown/plugins/rehype-tailwind/index.ts‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -327,19 +327,6 @@ export function rehypeTailwindClasses() {
327327
'text-xs',
328328
])
329329
}
330-
331-
// Share highlight custom element
332-
if (node.tagName === 'share-highlight') {
333-
node.properties = node.properties || {}
334-
node.properties['className'] = ((node.properties['className'] as string[]) || []).concat([
335-
'[--share-highlight-text-color:var(--color-gray-800)]',
336-
'[--share-highlight-bg-color:var(--color-gray-200)]',
337-
'[--share-highlight-text-color-active:var(--color-white)]',
338-
'[--share-highlight-bg-color-active:var(--color-blue-600)]',
339-
'[--share-highlight-tooltip-text-color:var(--color-white)]',
340-
'[--share-highlight-tooltip-bg-color:var(--color-gray-800)]',
341-
])
342-
}
343330
})
344331
}
345332
}

0 commit comments

Comments
 (0)