Skip to content

Commit

Permalink
refactor(frontend): prefix css variables (#14725)
Browse files Browse the repository at this point in the history
* wip

* Update index.d.ts

* remove unnecessary codes
  • Loading branch information
syuilo authored Oct 9, 2024
1 parent 0ad31bd commit 4a356f1
Show file tree
Hide file tree
Showing 280 changed files with 1,076 additions and 1,093 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -578,18 +578,18 @@ ESMではディレクトリインポートは廃止されているのと、デ
### Lighten CSS vars
``` css
color: hsl(from var(--accent) h s calc(l + 10));
color: hsl(from var(--MI_THEME-accent) h s calc(l + 10));
```
### Darken CSS vars
``` css
color: hsl(from var(--accent) h s calc(l - 10));
color: hsl(from var(--MI_THEME-accent) h s calc(l - 10));
```
### Add alpha to CSS vars
``` css
color: color(from var(--accent) srgb r g b / 0.5);
color: color(from var(--MI_THEME-accent) srgb r g b / 0.5);
```
2 changes: 1 addition & 1 deletion idea/MkDisableSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ defineProps<{
width: 100%;
height: 100%;
cursor: not-allowed;
--color: color(from var(--error) srgb r g b / 0.25);
--color: color(from var(--MI_THEME-error) srgb r g b / 0.25);
background-size: auto auto;
background-image: repeating-linear-gradient(135deg, transparent, transparent 10px, var(--color) 4px, var(--color) 14px);
}
Expand Down
4 changes: 0 additions & 4 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7705,10 +7705,6 @@ export interface Locale extends ILocale {
* 入力ボックスの縁取り
*/
"inputBorder": string;
/**
* リスト項目の背景 (ホバー)
*/
"listItemHoverBg": string;
/**
* ドライブフォルダーの背景
*/
Expand Down
1 change: 0 additions & 1 deletion locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2018,7 +2018,6 @@ _theme:
buttonBg: "ボタンの背景"
buttonHoverBg: "ボタンの背景 (ホバー)"
inputBorder: "入力ボックスの縁取り"
listItemHoverBg: "リスト項目の背景 (ホバー)"
driveFolderBg: "ドライブフォルダーの背景"
wallpaperOverlay: "壁紙のオーバーレイ"
badge: "バッジ"
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/web/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
const theme = localStorage.getItem('theme');
if (theme) {
for (const [k, v] of Object.entries(JSON.parse(theme))) {
document.documentElement.style.setProperty(`--${k}`, v.toString());
document.documentElement.style.setProperty(`--MI_THEME-${k}`, v.toString());

// HTMLの theme-color 適用
if (k === 'htmlThemeColor') {
Expand Down
8 changes: 4 additions & 4 deletions packages/backend/src/server/web/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/

html {
background-color: var(--bg);
color: var(--fg);
background-color: var(--MI_THEME-bg);
color: var(--MI_THEME-fg);
}

#splash {
Expand All @@ -17,7 +17,7 @@ html {
width: 100vw;
height: 100vh;
cursor: wait;
background-color: var(--bg);
background-color: var(--MI_THEME-bg);
opacity: 1;
transition: opacity 0.5s ease;
}
Expand Down Expand Up @@ -45,7 +45,7 @@ html {
width: 28px;
height: 28px;
transform: translateY(70px);
color: var(--accent);
color: var(--MI_THEME-accent);
}

#splashSpinner > .spinner {
Expand Down
10 changes: 5 additions & 5 deletions packages/backend/src/server/web/style.embed.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/

html {
background-color: var(--bg);
color: var(--fg);
background-color: var(--MI_THEME-bg);
color: var(--MI_THEME-fg);
}

html.embed {
Expand All @@ -24,7 +24,7 @@ html.embed {
width: 100vw;
height: 100vh;
cursor: wait;
background-color: var(--bg);
background-color: var(--MI_THEME-bg);
opacity: 1;
transition: opacity 0.5s ease;
}
Expand All @@ -33,7 +33,7 @@ html.embed #splash {
box-sizing: border-box;
min-height: 300px;
border-radius: var(--radius, 12px);
border: 1px solid var(--divider, #e8e8e8);
border: 1px solid var(--MI_THEME-divider, #e8e8e8);
}

html.embed.norounded #splash {
Expand Down Expand Up @@ -67,7 +67,7 @@ html.embed.noborder #splash {
width: 28px;
height: 28px;
transform: translateY(70px);
color: var(--accent);
color: var(--MI_THEME-accent);
}

#splashSpinner > .spinner {
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend-embed/src/components/EmLoading.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const props = withDefaults(defineProps<{
--size: 38px;
&.colored {
color: var(--accent);
color: var(--MI_THEME-accent);
}
&.inline {
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend-embed/src/components/EmMediaBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ defineProps<{
width: 100%;
padding: var(--margin);
margin-top: 4px;
border: 1px solid var(--inputBorder);
border: 1px solid var(--MI_THEME-inputBorder);
border-radius: var(--radius);
background-color: var(--panel);
background-color: var(--MI_THEME-panel);
transition: background-color .1s, border-color .1s;
&:hover {
text-decoration: none;
border-color: var(--inputBorderHover);
background-color: var(--buttonHoverBg);
border-color: var(--MI_THEME-inputBorderHover);
background-color: var(--MI_THEME-buttonHoverBg);
}
}
Expand Down
18 changes: 9 additions & 9 deletions packages/frontend-embed/src/components/EmMediaImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<div :class="$style.indicators">
<div v-if="['image/gif', 'image/apng'].includes(image.type)" :class="$style.indicator">GIF</div>
<div v-if="image.comment" :class="$style.indicator">ALT</div>
<div v-if="image.isSensitive" :class="$style.indicator" style="color: var(--warn);" :title="i18n.ts.sensitive"><i class="ti ti-eye-exclamation"></i></div>
<div v-if="image.isSensitive" :class="$style.indicator" style="color: var(--MI_THEME-warn);" :title="i18n.ts.sensitive"><i class="ti ti-eye-exclamation"></i></div>
</div>
<i v-if="!hide" class="ti ti-eye-off" :class="$style.hide" @click.stop="hide = true"></i>
</div>
Expand Down Expand Up @@ -94,8 +94,8 @@ async function onclick(ev: MouseEvent) {
display: block;
position: absolute;
border-radius: 6px;
background-color: var(--fg);
color: var(--accentLighten);
background-color: var(--MI_THEME-fg);
color: var(--MI_THEME-accentLighten);
font-size: 12px;
opacity: .5;
padding: 5px 8px;
Expand All @@ -114,19 +114,19 @@ async function onclick(ev: MouseEvent) {
.visible {
position: relative;
//box-shadow: 0 0 0 1px var(--divider) inset;
background: var(--bg);
//box-shadow: 0 0 0 1px var(--MI_THEME-divider) inset;
background: var(--MI_THEME-bg);
background-size: 16px 16px;
}
html[data-color-scheme=dark] .visible {
--c: rgb(255 255 255 / 2%);
background-image: linear-gradient(45deg, var(--c) 16.67%, var(--bg) 16.67%, var(--bg) 50%, var(--c) 50%, var(--c) 66.67%, var(--bg) 66.67%, var(--bg) 100%);
background-image: linear-gradient(45deg, var(--c) 16.67%, var(--MI_THEME-bg) 16.67%, var(--MI_THEME-bg) 50%, var(--c) 50%, var(--c) 66.67%, var(--MI_THEME-bg) 66.67%, var(--MI_THEME-bg) 100%);
}
html[data-color-scheme=light] .visible {
--c: rgb(0 0 0 / 2%);
background-image: linear-gradient(45deg, var(--c) 16.67%, var(--bg) 16.67%, var(--bg) 50%, var(--c) 50%, var(--c) 66.67%, var(--bg) 66.67%, var(--bg) 100%);
background-image: linear-gradient(45deg, var(--c) 16.67%, var(--MI_THEME-bg) 16.67%, var(--MI_THEME-bg) 50%, var(--c) 50%, var(--c) 66.67%, var(--MI_THEME-bg) 66.67%, var(--MI_THEME-bg) 100%);
}
.imageContainer {
Expand All @@ -150,10 +150,10 @@ html[data-color-scheme=light] .visible {
}
.indicator {
/* Hardcode to black because either --bg or --fg makes it hard to read in dark/light mode */
/* Hardcode to black because either --MI_THEME-bg or --MI_THEME-fg makes it hard to read in dark/light mode */
background-color: black;
border-radius: 6px;
color: var(--accentLighten);
color: var(--MI_THEME-accentLighten);
display: inline-block;
font-weight: bold;
font-size: 0.8em;
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend-embed/src/components/EmMediaVideo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ defineProps<{
height: auto;
aspect-ratio: 16 / 9;
padding: var(--margin);
border: 1px solid var(--divider);
border: 1px solid var(--MI_THEME-divider);
border-radius: var(--radius);
background-color: #000;
Expand All @@ -49,7 +49,7 @@ defineProps<{
}
.videoOverlayPlayButton {
background: var(--accent);
background: var(--MI_THEME-accent);
color: #fff;
padding: 1rem;
border-radius: 99rem;
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend-embed/src/components/EmMention.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const canonical = props.host === localHost ? `@${props.username}` : `@${props.us
const url = `/${canonical}`;
const bg = tinycolor(getComputedStyle(document.documentElement).getPropertyValue('--mention'));
const bg = tinycolor(getComputedStyle(document.documentElement).getPropertyValue('--MI_THEME-mention'));
bg.setAlpha(0.1);
const bgCss = bg.toRgbString();
</script>
Expand All @@ -37,7 +37,7 @@ const bgCss = bg.toRgbString();
display: inline-block;
padding: 4px 8px 4px 4px;
border-radius: 999px;
color: var(--mention);
color: var(--MI_THEME-mention);
}
.host {
Expand Down
10 changes: 5 additions & 5 deletions packages/frontend-embed/src/components/EmMfm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const QUOTE_STYLE = `
display: block;
margin: 8px;
padding: 6px 0 6px 12px;
color: var(--fg);
border-left: solid 3px var(--fg);
color: var(--MI_THEME-fg);
border-left: solid 3px var(--MI_THEME-fg);
opacity: 0.7;
`.split('\n').join(' ');

Expand Down Expand Up @@ -251,7 +251,7 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
}
case 'border': {
let color = validColor(token.props.args.color);
color = color ? `#${color}` : 'var(--accent)';
color = color ? `#${color}` : 'var(--MI_THEME-accent)';
let b_style = token.props.args.style;
if (
typeof b_style !== 'string' ||
Expand Down Expand Up @@ -284,7 +284,7 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
const child = token.children[0];
const unixtime = parseInt(child.type === 'text' ? child.props.text : '');
return h('span', {
style: 'display: inline-block; font-size: 90%; border: solid 1px var(--divider); border-radius: 999px; padding: 4px 10px 4px 6px;',
style: 'display: inline-block; font-size: 90%; border: solid 1px var(--MI_THEME-divider); border-radius: 999px; padding: 4px 10px 4px 6px;',
}, [
h('i', {
class: 'ti ti-clock',
Expand Down Expand Up @@ -355,7 +355,7 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
return [h(EmA, {
key: Math.random(),
to: isNote ? `/tags/${encodeURIComponent(token.props.hashtag)}` : `/user-tags/${encodeURIComponent(token.props.hashtag)}`,
style: 'color:var(--hashtag);',
style: 'color:var(--MI_THEME-hashtag);',
}, `#${token.props.hashtag}`)];
}

Expand Down
24 changes: 12 additions & 12 deletions packages/frontend-embed/src/components/EmNote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const isDeleted = ref(false);
margin: auto;
width: calc(100% - 8px);
height: calc(100% - 8px);
border: dashed 2px var(--focus);
border: dashed 2px var(--MI_THEME-focus);
border-radius: var(--radius);
box-sizing: border-box;
}
Expand All @@ -212,9 +212,9 @@ const isDeleted = ref(false);
right: 12px;
padding: 0 4px;
margin-bottom: 0 !important;
background: var(--popup);
background: var(--MI_THEME-popup);
border-radius: 8px;
box-shadow: 0px 4px 32px var(--shadow);
box-shadow: 0px 4px 32px var(--MI_THEME-shadow);
}
.footerButton {
Expand Down Expand Up @@ -259,7 +259,7 @@ const isDeleted = ref(false);
padding: 16px 32px 8px 32px;
line-height: 28px;
white-space: pre;
color: var(--renote);
color: var(--MI_THEME-renote);
& + .article {
padding-top: 8px;
Expand Down Expand Up @@ -382,7 +382,7 @@ const isDeleted = ref(false);
.showLessLabel {
display: inline-block;
background: var(--popup);
background: var(--MI_THEME-popup);
padding: 6px 10px;
font-size: 0.8em;
border-radius: 999px;
Expand All @@ -403,16 +403,16 @@ const isDeleted = ref(false);
z-index: 2;
width: 100%;
height: 64px;
background: linear-gradient(0deg, var(--panel), color(from var(--panel) srgb r g b / 0));
background: linear-gradient(0deg, var(--MI_THEME-panel), color(from var(--MI_THEME-panel) srgb r g b / 0));
&:hover > .collapsedLabel {
background: var(--panelHighlight);
background: var(--MI_THEME-panelHighlight);
}
}
.collapsedLabel {
display: inline-block;
background: var(--panel);
background: var(--MI_THEME-panel);
padding: 6px 10px;
font-size: 0.8em;
border-radius: 999px;
Expand All @@ -424,12 +424,12 @@ const isDeleted = ref(false);
}
.replyIcon {
color: var(--accent);
color: var(--MI_THEME-accent);
margin-right: 0.5em;
}
.translation {
border: solid 0.5px var(--divider);
border: solid 0.5px var(--MI_THEME-divider);
border-radius: var(--radius);
padding: 12px;
margin-top: 8px;
Expand All @@ -449,7 +449,7 @@ const isDeleted = ref(false);
.quoteNote {
padding: 16px;
border: dashed 1px var(--renote);
border: dashed 1px var(--MI_THEME-renote);
border-radius: 8px;
overflow: clip;
}
Expand All @@ -473,7 +473,7 @@ const isDeleted = ref(false);
}
&:hover {
color: var(--fgHighlighted);
color: var(--MI_THEME-fgHighlighted);
}
}
Expand Down
Loading

0 comments on commit 4a356f1

Please sign in to comment.