diff --git a/src/global.css b/src/global.css
index b92e554..393c015 100644
--- a/src/global.css
+++ b/src/global.css
@@ -100,15 +100,6 @@ tbody tr:last-child td {
padding-right: 0;
}
-pre {
- border-radius: var(--radius);
- padding: 1rem;
- background: var(--bg-hard);
- font: inherit;
- font-family: var(--font-mono);
- overflow-x: auto;
-}
-
.h2 {
margin-bottom: var(--vgap);
text-transform: lowercase;
@@ -361,6 +352,9 @@ input[type='range'] {
.data-options {
position: sticky;
top: 1rem;
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(28ch, 1fr));
+ gap: 1rem;
min-width: 20ch;
}
diff --git a/src/lib/components/combinations/Combinations.svelte b/src/lib/components/combinations/Combinations.svelte
index c2460ce..d5dc896 100644
--- a/src/lib/components/combinations/Combinations.svelte
+++ b/src/lib/components/combinations/Combinations.svelte
@@ -64,9 +64,6 @@
diff --git a/src/lib/components/export/DesignTokensExport.svelte b/src/lib/components/export/DesignTokensExport.svelte
index 8bb0cc1..079840c 100644
--- a/src/lib/components/export/DesignTokensExport.svelte
+++ b/src/lib/components/export/DesignTokensExport.svelte
@@ -3,6 +3,7 @@
import {permalink} from '$lib/routing';
import type {Entry} from '$lib/stores/combinations';
import {rootNode} from '$lib/stores/palette';
+ import CodeArea from './CodeArea.svelte';
export let entries: Entry[];
@@ -24,6 +25,8 @@
...tokens
}
};
+
+ $: code = JSON.stringify(json, null, 2);
-
{JSON.stringify(json, null, 2)}
+
diff --git a/src/lib/components/export/Export.svelte b/src/lib/components/export/Export.svelte
index a101686..7e5d48a 100644
--- a/src/lib/components/export/Export.svelte
+++ b/src/lib/components/export/Export.svelte
@@ -10,7 +10,8 @@
exportCasing,
exportColorFormat,
exportFormat,
- exportPrecision
+ exportPrecision,
+ exportPrefix
} from '$lib/stores/export';
import DesignTokensExport from './DesignTokensExport.svelte';
@@ -181,18 +182,30 @@
+
+
+
+
+
{/if}
{#if $exportFormat !== 'tokens' && $exportColorFormat !== 'hex' && $exportColorFormat !== 'rgb'}
-
-
+
+
+
+
{/if}
@@ -206,6 +219,7 @@
{entries}
format={$exportFormat}
casing={$exportCasing}
+ prefix={$exportPrefix}
/>
{/if}
diff --git a/src/lib/components/export/VariablesExport.svelte b/src/lib/components/export/VariablesExport.svelte
index d41f524..b43c0d7 100644
--- a/src/lib/components/export/VariablesExport.svelte
+++ b/src/lib/components/export/VariablesExport.svelte
@@ -8,20 +8,25 @@
import {rootNode} from '$lib/stores/palette';
import {cssRule, sassRule} from '$lib/utils/css';
import {camelCase, dashCase} from '$lib/utils/strings';
+ import CodeArea from './CodeArea.svelte';
export let entries: ExportEntry[];
export let format: ExportFormat;
export let casing: ExportCasing;
+ export let prefix: string;
$: formatRule = format === 'css' ? cssRule : sassRule;
$: formatCase = casing === 'dash' ? dashCase : camelCase;
$: variables = entries
.map(({name, cssColor}) =>
- formatRule(formatCase(name), cssColor)
+ formatRule(
+ formatCase(prefix ? `${prefix} ${name}` : name),
+ cssColor
+ )
)
.join('\n');
+
+ $: code = `/* @see ${permalink($rootNode)} */\n${variables}`;
-/* @see {permalink($rootNode)} */
-{variables}
-
+
diff --git a/src/lib/stores/export.ts b/src/lib/stores/export.ts
index 1241235..0f496ba 100644
--- a/src/lib/stores/export.ts
+++ b/src/lib/stores/export.ts
@@ -12,3 +12,4 @@ export const exportFormat = writable('table');
export const exportColorFormat = writable('hex');
export const exportCasing = writable('dash');
export const exportPrecision = writable(3);
+export const exportPrefix = writable('');
diff --git a/src/lib/utils/strings.ts b/src/lib/utils/strings.ts
index 4833a89..42f6ef6 100644
--- a/src/lib/utils/strings.ts
+++ b/src/lib/utils/strings.ts
@@ -1,3 +1,8 @@
+// Sass is more liberal than CSS in what chars are legal in
+// a variable name, but we're taking the stricter approach.
+const stripForbiddenChars = (text: string) =>
+ text.replaceAll(/[^a-zA-Z0-9_-]/g, '');
+
export const sentenceCase = (sentence: string) =>
sentence.charAt(0).toUpperCase() +
sentence.slice(1).toLowerCase();
@@ -5,12 +10,14 @@ export const sentenceCase = (sentence: string) =>
export const dashCase = (sentence: string) =>
sentence
.split(' ')
+ .map(stripForbiddenChars)
.map((word) => word.toLowerCase())
.join('-');
export const camelCase = (sentence: string) =>
sentence
.split(' ')
+ .map(stripForbiddenChars)
.map((word, index) =>
index === 0 ? word.toLowerCase() : sentenceCase(word)
)