From 44c659eb5aedf1cd3ed35e2bcac1238c0ab9fb24 Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Wed, 14 Aug 2024 10:47:52 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20unocss=E3=81=AE=E6=AD=A3=E3=81=97?= =?UTF-8?q?=E3=81=84theme=E3=81=AE=E8=A8=AD=E5=AE=9A=E3=81=AE=E4=BB=95?= =?UTF-8?q?=E6=96=B9=E3=82=92=E6=95=99=E3=81=88=E3=81=A6=E3=82=82=E3=82=89?= =?UTF-8?q?=E3=81=A3=E3=81=9F=E3=81=AE=E3=81=A7=E5=86=8D=E5=BA=A6=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/unocss/unocss/issues/3038#issuecomment-2287766398 --- uno.config.ts | 34 ++++++++++++++++++---------------- vite.config.ts | 6 ++---- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/uno.config.ts b/uno.config.ts index 3337494..ec1a79d 100644 --- a/uno.config.ts +++ b/uno.config.ts @@ -8,9 +8,26 @@ import { transformerVariantGroup, } from 'unocss'; +export const theme = { + colors: { + 'LP-blue': '#1ecfff', + 'LP-pink': '#ff00ff', + 'LP-yellow': '#ffffb3', + 'LP-gray': '#909296', + 'LP-dark-gray': '#5C5F66', + 'LP-backgroud': '#010a01', + 'LP-text-color': '#f8f9fa', + }, + breakpoints: { + tiny: '375px', + }, +} as const; + export default defineConfig({ presets: [ - presetUno(), // defaultの設定。 + presetUno({ + extendedTheme: theme, // `extendedTheme` を用いないと deep-merge されない https://github.com/unocss/unocss/issues/3038#issuecomment-2287766398 + }), presetAttributify({ prefix: 'uno-', prefixedOnly: true }), // class属性ではなく、属性地に直接書く設定。https://unocss.dev/presets/attributify presetIcons({ autoInstall: isDevelopment }), // Iconを使うための設定。autoInstallも設定している。https://unocss.dev/presets/icons ], @@ -25,21 +42,6 @@ export default defineConfig({ ], }, }, - theme: { - colors: { - 'LP-blue': '#1ecfff', - 'LP-pink': '#ff00ff', - 'LP-yellow': '#ffffb3', - 'LP-gray': '#909296', - 'LP-dark-gray': '#5C5F66', - 'LP-backgroud': '#010a01', - 'LP-text-color': '#f8f9fa', - }, - breakpoints: { - ...presetUno()?.theme?.breakpoints ?? {}, // https://github.com/unocss/unocss/issues/3038 - tiny: '375px', - }, - }, rules: [ ['p-safe', { padding: 'env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)' }], ['min-h-safe', { 'min-height': 'calc(100% + env(safe-area-inset-top))' }], diff --git a/vite.config.ts b/vite.config.ts index a624519..1a869c4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -7,7 +7,7 @@ import extractorSvelte from '@unocss/extractor-svelte'; import { cloudflareRedirect } from '@ryoppippi/vite-plugin-cloudflare-redirect'; import { faviconPlugin } from './plugins'; -import UnocssConfig from './uno.config.js'; +import { theme } from './uno.config.js'; import { LINKS, VIM_JP_RADIO_INFO } from './src/lib/links/_links.js'; function relativePath(...args: string[]): string { @@ -15,9 +15,7 @@ function relativePath(...args: string[]): string { } /* unocss から background color を取得 */ -// @ts-expect-error background color may be undefined -// eslint-disable-next-line ts/no-unsafe-member-access -const background = UnocssConfig?.theme?.colors?.['LP-backgroud'] as unknown; +const background = theme.colors['LP-backgroud']; if (typeof background !== 'string') { throw new TypeError('background color is not defined');