-
Notifications
You must be signed in to change notification settings - Fork 12
feat(theme): migrate to Tailwind CSS variables and refactor theme system #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d3b955a
efa60a0
caf750d
7c87c07
1fe078f
41d2ed4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| module.exports = { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be a misunderstanding. The |
||
| content: [ | ||
| "./docs/**/*.{md,mdx,js,ts,jsx,tsx}", | ||
| "./theme/**/*.{js,ts,jsx,tsx}", | ||
| ], | ||
| darkMode: ["selector"], | ||
| theme: { | ||
| extend: { | ||
| colors: { | ||
| background: "hsl(var(--background))", | ||
| foreground: "hsl(var(--foreground))", | ||
| primary: "hsl(var(--primary))", | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| @import "tailwindcss"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer to implement this pattern for our main project ( |
||
| @custom-variant dark (&:where(.dark, .dark *)); | ||
|
|
||
| @theme { | ||
| --color-background: hsl(0 0% 100%); | ||
| --color-foreground: hsl(222.2 84% 4.9%); | ||
| --color-primary: hsl(221.2 83.2% 53.3%); | ||
|
|
||
| --color-background: var(--background); | ||
| --color-foreground: var(--foreground); | ||
| --color-primary: var(--primary); | ||
|
|
||
| --rp-c-bg: var(--color-background); | ||
| --rp-c-text: var(--color-foreground); | ||
| --rp-c-brand: var(--color-primary); | ||
| --rp-c-brand-light: color-mix(in srgb, var(--color-primary) 80%, transparent); | ||
| } | ||
|
|
||
| :root { | ||
| --background: 0 0% 100%; | ||
| --foreground: 222.2 84% 4.9%; | ||
| --primary: 221.2 83.2% 53.3%; | ||
| } | ||
|
|
||
| .dark { | ||
| --background: 222.2 84% 4.9%; | ||
| --foreground: 210 40% 98%; | ||
| --primary: 217.2 91.2% 59.8%; | ||
| } | ||
|
|
||
| @layer base { | ||
| body { | ||
| @apply bg-background text-foreground; | ||
| } | ||
| } | ||
| @layer components { | ||
| .rspress-doc a { | ||
| @apply text-primary hover:underline; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,8 @@ import { useLang } from "rspress/runtime"; | |
| import { | ||
| HomeLayout as BasicHomeLayout, | ||
| Layout as BasicLayout, | ||
| // getCustomMDXComponent, | ||
| } from "rspress/theme"; | ||
| import "./styles/index.css"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rspress uses postcss, and we have already configured tailwindcss in postCSs.config.js, so this seems confusing. |
||
|
|
||
| function HomeLayout() { | ||
| // const { code: Code } = getCustomMDXComponent(); | ||
|
|
@@ -21,6 +21,7 @@ const Layout = () => { | |
| : "🚧 MateChat React 文档仍在开发中"} | ||
| </div> | ||
| } | ||
| // components={{ ... }} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,40 @@ | ||
| @import "tailwindcss"; | ||
|
|
||
| @custom-variant dark (&:where(.dark, .dark *)); | ||
|
|
||
| @theme { | ||
| --color-background: hsl(0 0% 100%); | ||
| --color-foreground: hsl(222.2 84% 4.9%); | ||
| --color-primary: hsl(221.2 83.2% 53.3%); | ||
|
|
||
| --color-background: var(--background); | ||
| --color-foreground: var(--foreground); | ||
| --color-primary: var(--primary); | ||
|
|
||
| --rp-c-bg: var(--color-background); | ||
| --rp-c-text: var(--color-foreground); | ||
| --rp-c-brand: var(--color-primary); | ||
| --rp-c-brand-light: color-mix(in srgb, var(--color-primary) 80%, transparent); | ||
| } | ||
|
|
||
| :root { | ||
| --background: 0 0% 100%; | ||
| --foreground: 222.2 84% 4.9%; | ||
| --primary: 221.2 83.2% 53.3%; | ||
| } | ||
|
|
||
| .dark { | ||
| --background: 222.2 84% 4.9%; | ||
| --foreground: 210 40% 98%; | ||
| --primary: 217.2 91.2% 59.8%; | ||
| } | ||
|
|
||
| @layer base { | ||
| body { | ||
| @apply bg-background text-foreground; | ||
| } | ||
| } | ||
| @layer components { | ||
| .rspress-doc a { | ||
| @apply text-primary hover:underline; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The autoprefix feature has been built in since tailwindcss v4. In addition, rspress is based on ByteDance's Rspack compiler, and the lightningcss used by Rspack also supports this function. This seems redundant.