Skip to content

Commit 6ec436b

Browse files
authored
add compose helpers and definition exports. (#37)
* trying out some ideas * switching branches * working on new compose helper * build outputs and new compose syntax * updates to compose helpers * move icons to compose helper * switching branch * compose helpers and exports for components * fixes & updates * fix icon loading in example * feedback changes * Update Readme * update storybook imports * feedback changes
1 parent 7217dae commit 6ec436b

File tree

232 files changed

+5095
-1322
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

232 files changed

+5095
-1322
lines changed

build/transform-fragments.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Reduces extra spaces in HTML tagged templates.
3+
*
4+
* @param {string} data - the fragment value
5+
* @returns string
6+
*/
7+
export function transformHTMLFragment(data) {
8+
data = data.replace(/\s*([<>])\s*/g, "$1"); // remove spaces before and after angle brackets
9+
return data.replace(/\s{2,}/g, " "); // Collapse all sequences to 1 space
10+
}
11+
12+
/**
13+
* Reduces extra spaces in CSS tagged templates.
14+
*
15+
* Breakdown of this regex:
16+
* (?:\s*\/\*(?:[\s\S])+?\*\/\s*) Remove comments (non-capturing)
17+
* (?:;)\s+(?=\}) Remove semicolons and spaces followed by property list end (non-capturing)
18+
* \s+(?=\{) Remove spaces before property list start (non-capturing)
19+
* (?<=:)\s+ Remove spaces after property declarations (non-capturing)
20+
* \s*([{};,])\s* Remove extra spaces before and after braces, semicolons, and commas (captures)
21+
*
22+
* @param {string} data - the fragment value
23+
* @returns string
24+
*/
25+
export function transformCSSFragment(data) {
26+
return data.replace(
27+
/(?:\s*\/\*(?:[\s\S])+?\*\/\s*)|(?:;)\s+(?=\})|\s+(?=\{)|(?<=:)\s+|\s*([{};,])\s*/g,
28+
"$1"
29+
);
30+
}

examples/use-adaptive-components/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
"start": "vite --open"
2525
},
2626
"dependencies": {
27-
"@adaptive-web/adaptive-web-components": "^0.0.1"
27+
"@adaptive-web/adaptive-web-components": "0.1.0"
2828
},
2929
"devDependencies": {
30+
"vite-plugin-svgo": "^1.2.0",
3031
"rimraf": "^3.0.2",
3132
"typescript": "^4.7.0",
3233
"vite": "^4.1.1"

examples/use-adaptive-components/src/index.ts

+16-17
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
// All components that are used in html must be defined.
2-
import AWC, {
3-
AvatarDefinition,
4-
ButtonDefinition,
5-
CardDefinition,
6-
RadioDefinition,
7-
RadioGroupDefinition,
8-
SwitchDefinition,
9-
TextFieldDefinition
10-
} from "@adaptive-web/adaptive-web-components";
11-
AWC.defineComponents({
12-
AvatarDefinition,
13-
ButtonDefinition,
14-
CardDefinition,
15-
RadioDefinition,
16-
RadioGroupDefinition,
17-
SwitchDefinition,
18-
// TextFieldDefinition // Uncomment to define the `adaptive-text-field` element.
2+
import { AdaptiveDesignSystem } from '@adaptive-web/adaptive-web-components';
3+
import { avatarDefinition } from "@adaptive-web/adaptive-web-components/avatar";
4+
import { buttonDefinition } from "@adaptive-web/adaptive-web-components/button";
5+
import { cardDefinition } from "@adaptive-web/adaptive-web-components/card";
6+
import { radioDefinition } from "@adaptive-web/adaptive-web-components/radio";
7+
import { radioGroupDefinition } from "@adaptive-web/adaptive-web-components/radio-group";
8+
import { switchDefinition } from "@adaptive-web/adaptive-web-components/switch";
9+
import { textFieldDefinition } from "@adaptive-web/adaptive-web-components/text-field";
10+
AdaptiveDesignSystem.defineComponents({
11+
avatarDefinition,
12+
buttonDefinition,
13+
cardDefinition,
14+
radioDefinition,
15+
radioGroupDefinition,
16+
switchDefinition,
17+
// textFieldDefinition // Uncomment to define the `adaptive-text-field` element.
1918
});
2019

2120
import { accentBaseColor, fillColor, LayerBaseLuminance, layerFillBaseLuminance, layerFillFixedBase } from "@adaptive-web/adaptive-ui";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { defineConfig } from "vite";
2+
import svg from 'vite-plugin-svgo'
3+
4+
export default defineConfig({
5+
plugins: [svg()]
6+
})

0 commit comments

Comments
 (0)