Compare commits
4 Commits
wasm-load
...
31cedd2547
Author | SHA1 | Date | |
---|---|---|---|
|
31cedd2547 | ||
|
7f6c217d7e | ||
|
ccedaa62a6 | ||
|
128eeb24ac |
@@ -84,43 +84,43 @@ impl M3SurfaceSet {
|
|||||||
pub fn to_css_variables(&self, prefix: &str) -> Vec<String> {
|
pub fn to_css_variables(&self, prefix: &str) -> Vec<String> {
|
||||||
let mut css_variables = Vec::new();
|
let mut css_variables = Vec::new();
|
||||||
|
|
||||||
css_variables.push(format!("--color-{}-surface: ${};", prefix, self.root));
|
css_variables.push(format!("--color-{}-surface: #{};", prefix, self.root));
|
||||||
css_variables.push(format!("--color-{}-surface-dim: ${};", prefix, self.dim));
|
css_variables.push(format!("--color-{}-surface-dim: #{};", prefix, self.dim));
|
||||||
css_variables.push(format!(
|
css_variables.push(format!(
|
||||||
"--color-{}-surface-bright: ${};",
|
"--color-{}-surface-bright: #{};",
|
||||||
prefix, self.bright
|
prefix, self.bright
|
||||||
));
|
));
|
||||||
css_variables.push(format!(
|
css_variables.push(format!(
|
||||||
"--color-{}-surface-container: ${};",
|
"--color-{}-surface-container: #{};",
|
||||||
prefix, self.container
|
prefix, self.container
|
||||||
));
|
));
|
||||||
css_variables.push(format!(
|
css_variables.push(format!(
|
||||||
"--color-{}-surface-container-lowest: ${};",
|
"--color-{}-surface-container-lowest: #{};",
|
||||||
prefix, self.container_lowest
|
prefix, self.container_lowest
|
||||||
));
|
));
|
||||||
css_variables.push(format!(
|
css_variables.push(format!(
|
||||||
"--color-{}-surface-container-low: ${};",
|
"--color-{}-surface-container-low: #{};",
|
||||||
prefix, self.container_low
|
prefix, self.container_low
|
||||||
));
|
));
|
||||||
css_variables.push(format!(
|
css_variables.push(format!(
|
||||||
"--color-{}-surface-container-high: ${};",
|
"--color-{}-surface-container-high: #{};",
|
||||||
prefix, self.container_high
|
prefix, self.container_high
|
||||||
));
|
));
|
||||||
css_variables.push(format!(
|
css_variables.push(format!(
|
||||||
"--color-{}-surface-container-highest: ${};",
|
"--color-{}-surface-container-highest: #{};",
|
||||||
prefix, self.container_highest
|
prefix, self.container_highest
|
||||||
));
|
));
|
||||||
css_variables.push(format!("--color-{}-on-surface: ${};", prefix, self.on_root));
|
css_variables.push(format!("--color-{}-on-surface: #{};", prefix, self.on_root));
|
||||||
css_variables.push(format!(
|
css_variables.push(format!(
|
||||||
"--color-{}-on-surface-variant: ${};",
|
"--color-{}-on-surface-variant: #{};",
|
||||||
prefix, self.on_root_variant
|
prefix, self.on_root_variant
|
||||||
));
|
));
|
||||||
css_variables.push(format!(
|
css_variables.push(format!(
|
||||||
"--color-{}-inverse-surface: ${};",
|
"--color-{}-inverse-surface: #{};",
|
||||||
prefix, self.inverse
|
prefix, self.inverse
|
||||||
));
|
));
|
||||||
css_variables.push(format!(
|
css_variables.push(format!(
|
||||||
"--color-{}-inverse-on-surface: ${};",
|
"--color-{}-inverse-on-surface: #{};",
|
||||||
prefix, self.on_inverse
|
prefix, self.on_inverse
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -130,43 +130,43 @@ impl M3SurfaceSet {
|
|||||||
pub fn to_scss_variables(&self, prefix: &str) -> Vec<String> {
|
pub fn to_scss_variables(&self, prefix: &str) -> Vec<String> {
|
||||||
let mut scss_variables = Vec::new();
|
let mut scss_variables = Vec::new();
|
||||||
|
|
||||||
scss_variables.push(format!("$color-{}-surface: ${};", prefix, self.root));
|
scss_variables.push(format!("$color-{}-surface: #{};", prefix, self.root));
|
||||||
scss_variables.push(format!("$color-{}-surface-dim: ${};", prefix, self.dim));
|
scss_variables.push(format!("$color-{}-surface-dim: #{};", prefix, self.dim));
|
||||||
scss_variables.push(format!(
|
scss_variables.push(format!(
|
||||||
"$color-{}-surface-bright: ${};",
|
"$color-{}-surface-bright: #{};",
|
||||||
prefix, self.bright
|
prefix, self.bright
|
||||||
));
|
));
|
||||||
scss_variables.push(format!(
|
scss_variables.push(format!(
|
||||||
"$color-{}-surface-container: ${};",
|
"$color-{}-surface-container: #{};",
|
||||||
prefix, self.container
|
prefix, self.container
|
||||||
));
|
));
|
||||||
scss_variables.push(format!(
|
scss_variables.push(format!(
|
||||||
"$color-{}-surface-container-lowest: ${};",
|
"$color-{}-surface-container-lowest: #{};",
|
||||||
prefix, self.container_lowest
|
prefix, self.container_lowest
|
||||||
));
|
));
|
||||||
scss_variables.push(format!(
|
scss_variables.push(format!(
|
||||||
"$color-{}-surface-container-low: ${};",
|
"$color-{}-surface-container-low: #{};",
|
||||||
prefix, self.container_low
|
prefix, self.container_low
|
||||||
));
|
));
|
||||||
scss_variables.push(format!(
|
scss_variables.push(format!(
|
||||||
"$color-{}-surface-container-high: ${};",
|
"$color-{}-surface-container-high: #{};",
|
||||||
prefix, self.container_high
|
prefix, self.container_high
|
||||||
));
|
));
|
||||||
scss_variables.push(format!(
|
scss_variables.push(format!(
|
||||||
"$color-{}-surface-container-highest: ${};",
|
"$color-{}-surface-container-highest: #{};",
|
||||||
prefix, self.container_highest
|
prefix, self.container_highest
|
||||||
));
|
));
|
||||||
scss_variables.push(format!("$color-{}-on-surface: ${};", prefix, self.on_root));
|
scss_variables.push(format!("$color-{}-on-surface: #{};", prefix, self.on_root));
|
||||||
scss_variables.push(format!(
|
scss_variables.push(format!(
|
||||||
"$color-{}-on-surface-variant: ${};",
|
"$color-{}-on-surface-variant: #{};",
|
||||||
prefix, self.on_root_variant
|
prefix, self.on_root_variant
|
||||||
));
|
));
|
||||||
scss_variables.push(format!(
|
scss_variables.push(format!(
|
||||||
"$color-{}-inverse-surface: ${};",
|
"$color-{}-inverse-surface: #{};",
|
||||||
prefix, self.inverse
|
prefix, self.inverse
|
||||||
));
|
));
|
||||||
scss_variables.push(format!(
|
scss_variables.push(format!(
|
||||||
"$color-{}-inverse-on-surface: ${};",
|
"$color-{}-inverse-on-surface: #{};",
|
||||||
prefix, self.on_inverse
|
prefix, self.on_inverse
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@@ -42,7 +42,6 @@ export function ColorFunctionProvider({ children }: WasmProviderProps) {
|
|||||||
try {
|
try {
|
||||||
await init();
|
await init();
|
||||||
setWasmInstance(funcs);
|
setWasmInstance(funcs);
|
||||||
console.debug('[Load WASM]', 'Loaded');
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Load WASM]', e);
|
console.error('[Load WASM]', e);
|
||||||
setError(e);
|
setError(e);
|
||||||
|
@@ -6,6 +6,7 @@ import { HSegmentedControl } from '../components/HSegmentedControl';
|
|||||||
import { ScrollArea } from '../components/ScrollArea';
|
import { ScrollArea } from '../components/ScrollArea';
|
||||||
import { ColorDescription } from '../models';
|
import { ColorDescription } from '../models';
|
||||||
import { ColorCard } from '../page-components/cards-detail/ColorCard';
|
import { ColorCard } from '../page-components/cards-detail/ColorCard';
|
||||||
|
import { mapToObject } from '../utls';
|
||||||
import styles from './CardsDetail.module.css';
|
import styles from './CardsDetail.module.css';
|
||||||
|
|
||||||
type ColorModes = 'hex' | 'rgb' | 'hsl' | 'lab' | 'oklch';
|
type ColorModes = 'hex' | 'rgb' | 'hsl' | 'lab' | 'oklch';
|
||||||
@@ -20,7 +21,11 @@ export function CardsDetail({ mainTag }: CardsDetailProps) {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const embededCategories = colorFn.color_categories() as { label: string; value: string }[];
|
const embededCategories = colorFn.color_categories().map(mapToObject) as {
|
||||||
|
label: string;
|
||||||
|
value: string;
|
||||||
|
}[];
|
||||||
|
console.debug('[Fetch color categories]', embededCategories);
|
||||||
return embededCategories.filter((cate) => !isEqual(cate.value, 'unknown'));
|
return embededCategories.filter((cate) => !isEqual(cate.value, 'unknown'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Fetch color categories]', e);
|
console.error('[Fetch color categories]', e);
|
||||||
|
@@ -10,4 +10,7 @@ export default defineConfig({
|
|||||||
cssModules: true,
|
cssModules: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
optimizeDeps: {
|
||||||
|
exclude: ['color-module'],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user