-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: simplify UnoCSS integration (#270)
- Loading branch information
1 parent
d6d19c4
commit 8d49ef8
Showing
18 changed files
with
321 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,5 @@ | ||
import { unoCSSConfig } from '@tutorialkit/astro'; | ||
import { globSync, convertPathToPattern } from 'fast-glob'; | ||
import fs from 'node:fs/promises'; | ||
import { basename, dirname, join } from 'node:path'; | ||
import { defineConfig, presetIcons, presetUno, transformerDirectives } from 'unocss'; | ||
|
||
const iconPaths = globSync('./icons/languages/*.svg'); | ||
|
||
const customIconCollection = iconPaths.reduce( | ||
(acc, iconPath) => { | ||
const collectionName = basename(dirname(iconPath)); | ||
const [iconName] = basename(iconPath).split('.'); | ||
|
||
acc[collectionName] ??= {}; | ||
acc[collectionName][iconName] = async () => fs.readFile(iconPath, 'utf8'); | ||
|
||
return acc; | ||
}, | ||
{} as Record<string, Record<string, () => Promise<string>>>, | ||
); | ||
import { defineConfig } from '@tutorialkit/theme'; | ||
|
||
export default defineConfig({ | ||
...unoCSSConfig, | ||
content: { | ||
inline: globSync([ | ||
`${convertPathToPattern(join(require.resolve('@tutorialkit/components-react'), '..'))}/**/*.js`, | ||
`${convertPathToPattern(join(require.resolve('@tutorialkit/astro'), '..'))}/default/**/*.astro`, | ||
]).map((filePath) => { | ||
return () => fs.readFile(filePath, { encoding: 'utf8' }); | ||
}), | ||
}, | ||
transformers: [transformerDirectives()], | ||
presets: [ | ||
presetUno({ | ||
dark: { | ||
dark: '[data-theme="dark"]', | ||
}, | ||
}), | ||
presetIcons({ | ||
collections: { | ||
...customIconCollection, | ||
}, | ||
}), | ||
], | ||
// add your UnoCSS config here: https://unocss.dev/guide/config-file | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,5 @@ | ||
import { theme, rules, shortcuts } from '@tutorialkit/theme'; | ||
import { convertPathToPattern, globSync } from 'fast-glob'; | ||
import fs from 'node:fs/promises'; | ||
import { join } from 'path'; | ||
import { defineConfig, presetIcons, presetUno, transformerDirectives } from 'unocss'; | ||
import { defineConfig } from '@tutorialkit/theme'; | ||
|
||
export default defineConfig({ | ||
theme, | ||
rules, | ||
shortcuts, | ||
content: { | ||
inline: globSync( | ||
`${convertPathToPattern(join(require.resolve('@tutorialkit/components-react'), '..'))}/**/*.js`, | ||
).map((filePath) => { | ||
return () => fs.readFile(filePath, { encoding: 'utf8' }); | ||
}), | ||
}, | ||
transformers: [transformerDirectives()], | ||
presets: [presetUno(), presetIcons()], | ||
// add your UnoCSS config here: https://unocss.dev/guide/config-file | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,5 @@ | ||
import fs from 'node:fs/promises'; | ||
import { basename, dirname, join } from 'node:path'; | ||
import { globSync, convertPathToPattern } from 'fast-glob'; | ||
import { defineConfig, presetIcons, presetUno, transformerDirectives } from 'unocss'; | ||
import { rules, shortcuts, theme } from '@tutorialkit/theme'; | ||
|
||
const iconPaths = globSync('./icons/languages/*.svg'); | ||
|
||
const customIconCollection = iconPaths.reduce( | ||
(acc, iconPath) => { | ||
const collectionName = basename(dirname(iconPath)); | ||
const [iconName] = basename(iconPath).split('.'); | ||
|
||
acc[collectionName] ??= {}; | ||
acc[collectionName][iconName] = async () => fs.readFile(iconPath, 'utf8'); | ||
|
||
return acc; | ||
}, | ||
{} as Record<string, Record<string, () => Promise<string>>>, | ||
); | ||
import { defineConfig } from '@tutorialkit/theme'; | ||
|
||
export default defineConfig({ | ||
rules, | ||
shortcuts, | ||
theme, | ||
content: { | ||
inline: globSync([ | ||
`${convertPathToPattern(join(require.resolve('@tutorialkit/components-react'), '..')).replace('\\@', '/@')}/**/*.js`, | ||
`${convertPathToPattern(join(require.resolve('@tutorialkit/astro'), '..')).replace('\\@', '/@')}/default/**/*.astro`, | ||
]).map((filePath) => { | ||
return () => fs.readFile(filePath, { encoding: 'utf8' }); | ||
}), | ||
}, | ||
transformers: [transformerDirectives()], | ||
presets: [ | ||
presetUno({ | ||
dark: { | ||
dark: '[data-theme="dark"]', | ||
}, | ||
}), | ||
presetIcons({ | ||
collections: { | ||
...customIconCollection, | ||
}, | ||
}), | ||
], | ||
// add your UnoCSS config here: https://unocss.dev/guide/config-file | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/components/react/src/core/CodeMirrorEditor/cm-theme.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,5 @@ | ||
import { unoCSSConfig } from '@tutorialkit/astro'; | ||
import { globSync, convertPathToPattern } from 'fast-glob'; | ||
import fs from 'node:fs/promises'; | ||
import { basename, dirname, join } from 'node:path'; | ||
import { defineConfig, presetIcons, presetUno, transformerDirectives } from 'unocss'; | ||
|
||
const iconPaths = globSync('./icons/languages/*.svg'); | ||
|
||
const customIconCollection = iconPaths.reduce( | ||
(acc, iconPath) => { | ||
const collectionName = basename(dirname(iconPath)); | ||
const [iconName] = basename(iconPath).split('.'); | ||
|
||
acc[collectionName] ??= {}; | ||
acc[collectionName][iconName] = async () => fs.readFile(iconPath, 'utf8'); | ||
|
||
return acc; | ||
}, | ||
{} as Record<string, Record<string, () => Promise<string>>>, | ||
); | ||
import { defineConfig } from '@tutorialkit/theme'; | ||
|
||
export default defineConfig({ | ||
...unoCSSConfig, | ||
content: { | ||
inline: globSync([ | ||
`${convertPathToPattern(join(require.resolve('@tutorialkit/components-react'), '..')).replace('\\@', '/@')}/**/*.js`, | ||
`${convertPathToPattern(join(require.resolve('@tutorialkit/astro'), '..')).replace('\\@', '/@')}/default/**/*.astro`, | ||
]).map((filePath) => { | ||
return () => fs.readFile(filePath, { encoding: 'utf8' }); | ||
}), | ||
}, | ||
transformers: [transformerDirectives()], | ||
presets: [ | ||
presetUno({ | ||
dark: { | ||
dark: '[data-theme="dark"]', | ||
}, | ||
}), | ||
presetIcons({ | ||
collections: { | ||
...customIconCollection, | ||
}, | ||
}), | ||
], | ||
// add your UnoCSS config here: https://unocss.dev/guide/config-file | ||
}); |
Oops, something went wrong.