Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/cli/src/utils/park-ui-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { FileError, ParkUIConfigInvalid, ParkUIConfigNotFound } from './errors'

const ConfigSchema = Schema.Struct({
framework: Schema.Literal('react', 'solid', 'svelte', 'vue'),
imports: Schema.optional(
Schema.Struct({
'styled-system-base': Schema.optional(Schema.String),
}),
),
paths: Schema.Struct({
components: Schema.String,
theme: Schema.String,
Expand Down
18 changes: 14 additions & 4 deletions packages/cli/src/utils/registry-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@ const saveFiles = (files: RegistryFile[] = []) =>
Effect.forEach(files, (file) =>
Effect.all([
Effect.tryPromise({
try: () =>
outputFile(
try: () => {
// Replace styled-system imports if configured
let content = file.content
if (config.imports?.['styled-system-base']) {
content = content.replace(
/from ['"]styled-system\//g,
`from '${config.imports['styled-system-base']}/`,
)
}

return outputFile(
Match.value(file).pipe(
Match.when({ type: 'component' }, ({ fileName }) =>
join(config.paths.components, fileName),
Expand All @@ -37,8 +46,9 @@ const saveFiles = (files: RegistryFile[] = []) =>
),
Match.orElse(() => file.fileName),
),
file.content,
),
content,
)
},
catch: () => FileError(file.fileName),
}),

Expand Down
8 changes: 8 additions & 0 deletions website/public/schema/park-ui-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
"type": "string",
"enum": ["react", "solid", "vue", "svelte"]
},
"imports": {
"type": "object",
"properties": {
"styled-system-base": {
"type": "string"
}
}
},
"paths": {
"type": "object",
"required": ["components", "theme"],
Expand Down
19 changes: 18 additions & 1 deletion website/src/content/docs/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,21 @@ export default function Home() {

That's it! Happy hacking! ✌️
</Step>
</Steps>
</Steps>

## Additional configuration

If you need to customise the import path for styled-system because of TypeScript configuration, you can do so by updating the `park-ui.config.json` file.

```json
{
"framework": "react",
"paths": {
"components": "./src/components/ui",
"theme": "./src/theme"
},
"imports": {
"styled-system-base": "./app/styled-system"
}
}
```