mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-24 13:15:45 +00:00
Merge branch 'main' of github.com:shadcn/ui
This commit is contained in:
5
.changeset/forty-rabbits-wonder.md
Normal file
5
.changeset/forty-rabbits-wonder.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"shadcn": patch
|
||||
---
|
||||
|
||||
fix theme values bug
|
||||
@@ -196,12 +196,14 @@ async function addTailwindConfigTheme(
|
||||
const themeObject = await parseObjectLiteral(themeObjectString)
|
||||
const result = deepmerge(themeObject, theme)
|
||||
const resultString = objectToString(result)
|
||||
.replace(/\'\"/g, "'")
|
||||
.replace(/\"\'/g, "'")
|
||||
.replace(/\'\[/g, "[")
|
||||
.replace(/\]\'/g, "]")
|
||||
.replace(/\\\'/g, "")
|
||||
.replace(/\\\'/g, "")
|
||||
.replace(/\'\"/g, "'") // Replace `\" with "
|
||||
.replace(/\"\'/g, "'") // Replace `\" with "
|
||||
.replace(/\'\[/g, "[") // Replace `[ with [
|
||||
.replace(/\]\'/g, "]") // Replace `] with ]
|
||||
.replace(/\'\\\'/g, "'") // Replace `\' with '
|
||||
.replace(/\\\'/g, "'") // Replace \' with '
|
||||
.replace(/\\\'\'/g, "'")
|
||||
.replace(/\'\'/g, "'")
|
||||
themeInitializer.replaceWithText(resultString)
|
||||
}
|
||||
|
||||
|
||||
@@ -369,6 +369,41 @@ export default config
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`transformTailwindConfig -> theme > should keep quotes in strings 1`] = `
|
||||
"import type { Config } from 'tailwindcss'
|
||||
|
||||
const config: Config = {
|
||||
darkMode: ["class"],
|
||||
content: [
|
||||
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
"./components/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
"./app/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
],
|
||||
theme: {
|
||||
extend: {
|
||||
fontFamily: {
|
||||
sans: ['Figtree', ...defaultTheme.fontFamily.sans]
|
||||
},
|
||||
colors: {
|
||||
...defaultColors,
|
||||
background: 'hsl(var(--background))',
|
||||
foreground: 'hsl(var(--foreground))',
|
||||
primary: {
|
||||
DEFAULT: 'hsl(var(--primary))',
|
||||
foreground: 'hsl(var(--primary-foreground))'
|
||||
},
|
||||
card: {
|
||||
DEFAULT: 'hsl(var(--card))',
|
||||
foreground: 'hsl(var(--card-foreground))'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
export default config
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`transformTailwindConfig -> theme > should keep spread assignments 1`] = `
|
||||
"import type { Config } from 'tailwindcss'
|
||||
|
||||
|
||||
@@ -760,6 +760,55 @@ export default config
|
||||
expect(output3).toBe(output1)
|
||||
expect(output3).toBe(output2)
|
||||
})
|
||||
|
||||
test("should keep quotes in strings", async () => {
|
||||
expect(
|
||||
await transformTailwindConfig(
|
||||
`import type { Config } from 'tailwindcss'
|
||||
|
||||
const config: Config = {
|
||||
content: [
|
||||
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
"./components/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
"./app/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
],
|
||||
theme: {
|
||||
extend: {
|
||||
fontFamily: {
|
||||
sans: ['Figtree', ...defaultTheme.fontFamily.sans],
|
||||
},
|
||||
colors: {
|
||||
...defaultColors,
|
||||
background: "hsl(var(--background))",
|
||||
foreground: "hsl(var(--foreground))",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
export default config
|
||||
`,
|
||||
{
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
primary: {
|
||||
DEFAULT: "hsl(var(--primary))",
|
||||
foreground: "hsl(var(--primary-foreground))",
|
||||
},
|
||||
card: {
|
||||
DEFAULT: "hsl(var(--card))",
|
||||
foreground: "hsl(var(--card-foreground))",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
config: SHARED_CONFIG,
|
||||
}
|
||||
)
|
||||
).toMatchSnapshot()
|
||||
})
|
||||
})
|
||||
|
||||
describe("nestSpreadProperties", () => {
|
||||
|
||||
Reference in New Issue
Block a user