vira 2.2.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** This file is automatically updated by update-element-exports.ts */
1
+ /** This file is automatically updated by update-index-exports.ts */
2
2
  export * from './define-vira-element';
3
3
  export * from './vira-button/vira-button.element';
4
4
  export * from './vira-collapsible/vira-collapsible-wrapper.element';
@@ -1,4 +1,4 @@
1
- /** This file is automatically updated by update-element-exports.ts */
1
+ /** This file is automatically updated by update-index-exports.ts */
2
2
  export * from './define-vira-element';
3
3
  export * from './vira-button/vira-button.element';
4
4
  export * from './vira-collapsible/vira-collapsible-wrapper.element';
@@ -64,8 +64,8 @@ export const ViraButton = defineViraElement()({
64
64
  }
65
65
 
66
66
  button {
67
- cursor: pointer;
68
67
  ${noNativeFormStyles};
68
+ cursor: pointer;
69
69
  position: relative;
70
70
  width: 100%;
71
71
  height: 100%;
@@ -1,4 +1,5 @@
1
1
  import { TemplateResult } from 'element-vir';
2
+ import { viraIconCssVars } from './icon-css-vars';
2
3
  export type ViraIconSvg = {
3
4
  name: string;
4
5
  svgTemplate: TemplateResult;
@@ -7,3 +8,4 @@ export declare function defineIcon({ name, svgTemplate, }: {
7
8
  name: string;
8
9
  svgTemplate: TemplateResult;
9
10
  }): ViraIconSvg;
11
+ export declare function createColoredIcon(icon: ViraIconSvg, colors: Partial<Record<keyof typeof viraIconCssVars, string>>): ViraIconSvg;
@@ -1,3 +1,7 @@
1
+ import { getObjectTypedKeys } from '@augment-vir/common';
2
+ import { html } from 'element-vir';
3
+ import { getAssertedValidColor } from '../styles/color';
4
+ import { viraIconCssVars } from './icon-css-vars';
1
5
  export function defineIcon({ name, svgTemplate, }) {
2
6
  const iconSvg = {
3
7
  name,
@@ -5,3 +9,18 @@ export function defineIcon({ name, svgTemplate, }) {
5
9
  };
6
10
  return iconSvg;
7
11
  }
12
+ export function createColoredIcon(icon, colors) {
13
+ const colorStyles = getObjectTypedKeys(colors)
14
+ .map((cssVarName) => {
15
+ const colorValue = colors[cssVarName];
16
+ const color = getAssertedValidColor(colorValue);
17
+ return `${viraIconCssVars[cssVarName].name}: ${color.toString()};`;
18
+ })
19
+ .join(' ');
20
+ return defineIcon({
21
+ name: icon.name,
22
+ svgTemplate: html `
23
+ <div style=${colorStyles}>${icon.svgTemplate}</div>
24
+ `,
25
+ });
26
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ /** This file is automatically updated by update-root-index-exports.ts */
1
2
  export * from './elements';
2
3
  export * from './icons';
4
+ export * from './re-exports';
3
5
  export * from './styles';
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ /** This file is automatically updated by update-root-index-exports.ts */
1
2
  export * from './elements';
2
3
  export * from './icons';
4
+ export * from './re-exports';
3
5
  export * from './styles';
@@ -0,0 +1,5 @@
1
+ import ColorImport from 'colorjs.io';
2
+ export type { ColorTypes } from 'colorjs.io/types/src/color';
3
+ export type { Format } from 'colorjs.io/types/src/space';
4
+ export type Color = typeof ColorImport;
5
+ export declare const Color: Color;
@@ -0,0 +1,2 @@
1
+ import ColorImport from 'colorjs.io';
2
+ export const Color = ColorImport;
@@ -0,0 +1,2 @@
1
+ /** This file is automatically updated by update-index-exports.ts */
2
+ export * from './colorjs-io';
@@ -0,0 +1,2 @@
1
+ /** This file is automatically updated by update-index-exports.ts */
2
+ export * from './colorjs-io';
@@ -0,0 +1,4 @@
1
+ import { Format } from 'colorjs.io/types/src/space';
2
+ import { ColorTypes } from '../re-exports/colorjs-io';
3
+ export declare function getAssertedValidColor(input: ColorTypes | undefined): import("colorjs.io/types/src/color").default;
4
+ export declare const rgbCssColorFormat: Format;
@@ -0,0 +1,26 @@
1
+ import { wrapInTry } from '@augment-vir/common';
2
+ import { Color } from '../re-exports/colorjs-io';
3
+ export function getAssertedValidColor(input) {
4
+ try {
5
+ if (!input) {
6
+ throw new Error('invalid empty color');
7
+ }
8
+ return new Color(input);
9
+ }
10
+ catch (caught) {
11
+ const stringInput = String(input);
12
+ const inputForMessage = stringInput.toLowerCase().match(/\[\s*object\s+object\s*\]/)
13
+ ? wrapInTry({ callback: () => JSON.stringify(input), fallbackValue: stringInput })
14
+ : stringInput;
15
+ throw new Error(`Invalid color: ${inputForMessage}`);
16
+ }
17
+ }
18
+ export const rgbCssColorFormat = {
19
+ name: 'rgb',
20
+ coords: [
21
+ '<number>[0, 255]',
22
+ '<number>[0, 255]',
23
+ '<number>[0, 255]',
24
+ ],
25
+ commas: true,
26
+ };
@@ -1,6 +1,9 @@
1
+ /** This file is automatically updated by update-index-exports.ts */
2
+ export * from './color';
1
3
  export * from './disabled';
2
4
  export * from './durations';
3
5
  export * from './focus';
4
6
  export * from './native-styles';
5
7
  export * from './scrollbar';
6
8
  export * from './user-select';
9
+ export * from './vira-css-vars';
@@ -1,6 +1,9 @@
1
+ /** This file is automatically updated by update-index-exports.ts */
2
+ export * from './color';
1
3
  export * from './disabled';
2
4
  export * from './durations';
3
5
  export * from './focus';
4
6
  export * from './native-styles';
5
7
  export * from './scrollbar';
6
8
  export * from './user-select';
9
+ export * from './vira-css-vars';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vira",
3
- "version": "2.2.2",
3
+ "version": "2.3.0",
4
4
  "description": "A simple and highly versatile design system using element-vir.",
5
5
  "keywords": [
6
6
  "design",
@@ -40,15 +40,15 @@
40
40
  "test:docs": "virmator code-in-markdown check"
41
41
  },
42
42
  "dependencies": {
43
- "@augment-vir/common": "^18.0.0",
44
- "element-vir": "^16.3.1",
45
- "lit-css-vars": "^3.0.0",
46
- "spa-router-vir": "^3.0.0",
43
+ "@augment-vir/common": "^18.1.0",
44
+ "element-vir": "^16.3.2",
45
+ "lit-css-vars": "^3.0.1",
46
+ "spa-router-vir": "^3.0.2",
47
47
  "type-fest": "^4.3.1"
48
48
  },
49
49
  "devDependencies": {
50
- "@augment-vir/browser-testing": "^18.0.0",
51
- "@augment-vir/node-js": "^18.0.0",
50
+ "@augment-vir/browser-testing": "^18.1.0",
51
+ "@augment-vir/node-js": "^18.1.0",
52
52
  "@open-wc/testing": "^3.2.0",
53
53
  "@types/chai": "^4.3.6",
54
54
  "@types/mocha": "^10.0.1",
@@ -61,6 +61,6 @@
61
61
  "istanbul-smart-text-reporter": "^1.1.2",
62
62
  "typescript": "^5.2.2",
63
63
  "vite": "^4.4.9",
64
- "vite-tsconfig-paths": "^4.2.0"
64
+ "vite-tsconfig-paths": "^4.2.1"
65
65
  }
66
66
  }