Skip to content

Commit 0d69f14

Browse files
committed
WIP first build
1 parent 7d078b2 commit 0d69f14

File tree

168 files changed

+11408
-4310
lines changed

Some content is hidden

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

168 files changed

+11408
-4310
lines changed

LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,31 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2525
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2626
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2727
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
29+
---
30+
31+
This project code source is modified from `@microsoft/fast-components` licensed under
32+
33+
FAST - https://www.fast.design/
34+
35+
MIT License
36+
37+
Copyright (c) Microsoft Corporation. All rights reserved.
38+
39+
Permission is hereby granted, free of charge, to any person obtaining a copy
40+
of this software and associated documentation files (the "Software"), to deal
41+
in the Software without restriction, including without limitation the rights
42+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
43+
copies of the Software, and to permit persons to whom the Software is
44+
furnished to do so, subject to the following conditions:
45+
46+
The above copyright notice and this permission notice shall be included in all
47+
copies or substantial portions of the Software.
48+
49+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
50+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
51+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
52+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
53+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
54+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
55+
SOFTWARE

packages/components/karma.conf.cjs

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
const path = require("path");
2+
3+
const basePath = path.resolve(__dirname);
4+
5+
const commonChromeFlags = [
6+
"--no-default-browser-check",
7+
"--no-first-run",
8+
"--no-sandbox",
9+
"--no-managed-user-acknowledgment-check",
10+
"--disable-background-timer-throttling",
11+
"--disable-backing-store-limit",
12+
"--disable-boot-animation",
13+
"--disable-cloud-import",
14+
"--disable-contextual-search",
15+
"--disable-default-apps",
16+
"--disable-extensions",
17+
"--disable-infobars",
18+
"--disable-translate",
19+
];
20+
21+
module.exports = function (config) {
22+
let browsers;
23+
if (process.env.BROWSERS) {
24+
browsers = [process.env.BROWSERS];
25+
} else if (config.browsers) {
26+
browsers = config.browsers;
27+
} else {
28+
browsers = ["Chrome"];
29+
}
30+
31+
const setup = "setup-browser" + (config.package ? "-" + config.package : "");
32+
const options = {
33+
basePath,
34+
browserDisconnectTimeout: 10000,
35+
processKillTimeout: 10000,
36+
frameworks: ["source-map-support", "mocha"],
37+
plugins: [
38+
require("karma-mocha"),
39+
require("karma-mocha-reporter"),
40+
require("karma-webpack"),
41+
require("karma-source-map-support"),
42+
require("karma-sourcemap-loader"),
43+
require("karma-coverage-istanbul-reporter"),
44+
require("karma-chrome-launcher"),
45+
require("karma-firefox-launcher"),
46+
],
47+
files: [`dist/esm/__test__/${setup}.js`],
48+
preprocessors: {
49+
[`dist/esm/__test__/${setup}.js`]: ["webpack", "sourcemap"],
50+
},
51+
webpackMiddleware: {
52+
// webpack-dev-middleware configuration
53+
// i. e.
54+
stats: "errors-only",
55+
},
56+
webpack: {
57+
mode: "none",
58+
resolve: {
59+
extensions: [".js"],
60+
modules: ["dist", "node_modules"],
61+
mainFields: ["module", "main"],
62+
},
63+
devtool: "inline-source-map",
64+
performance: {
65+
hints: false,
66+
},
67+
optimization: {
68+
namedModules: false,
69+
namedChunks: false,
70+
nodeEnv: false,
71+
usedExports: true,
72+
flagIncludedChunks: false,
73+
occurrenceOrder: false,
74+
sideEffects: true,
75+
concatenateModules: true,
76+
splitChunks: {
77+
name: false,
78+
},
79+
runtimeChunk: false,
80+
noEmitOnErrors: false,
81+
checkWasmTypes: false,
82+
minimize: false,
83+
},
84+
module: {
85+
rules: [
86+
{
87+
test: /\.js\.map$/,
88+
use: ["ignore-loader"],
89+
},
90+
{
91+
test: /\.js$/,
92+
use: [
93+
{
94+
loader: "source-map-loader",
95+
options: {
96+
enforce: "pre",
97+
},
98+
},
99+
],
100+
},
101+
],
102+
},
103+
},
104+
mime: {
105+
"text/x-typescript": ["ts"],
106+
},
107+
reporters: [config.reporter || (process.env.CI ? "min" : "progress")],
108+
browsers: browsers,
109+
customLaunchers: {
110+
ChromeDebugging: {
111+
base: "Chrome",
112+
flags: [...commonChromeFlags, "--remote-debugging-port=9333"],
113+
debug: true,
114+
},
115+
ChromeHeadlessOpt: {
116+
base: "ChromeHeadless",
117+
flags: [...commonChromeFlags],
118+
},
119+
},
120+
client: {
121+
captureConsole: true,
122+
mocha: {
123+
bail: config["bail"],
124+
ui: "bdd",
125+
timeout: 5000,
126+
},
127+
},
128+
logLevel: config.LOG_ERROR, // to disable the WARN 404 for image requests
129+
};
130+
131+
if (config.coverage) {
132+
options.webpack.module.rules.push({
133+
enforce: "post",
134+
exclude: /(__tests__|testing|node_modules|\.spec\.[tj]s$)/,
135+
loader: "istanbul-instrumenter-loader",
136+
options: { esModules: true },
137+
test: /\.[tj]s$/,
138+
});
139+
options.reporters = ["coverage-istanbul", ...options.reporters];
140+
options.coverageIstanbulReporter = {
141+
reports: ["html", "text-summary", "json", "lcovonly", "cobertura"],
142+
dir: "coverage",
143+
};
144+
options.junitReporter = {
145+
outputDir: "coverage",
146+
outputFile: "test-results.xml",
147+
useBrowserName: false,
148+
};
149+
}
150+
151+
config.set(options);
152+
};

packages/components/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"main": "dist/esm/index.js",
2222
"types": "dist/dts/index.d.ts",
2323
"sideEffects": false,
24+
"type": "module",
2425
"scripts": {
2526
"start": "storybook dev -p 6006",
2627
"start:ci": "storybook dev -p 6006 --ci --quiet",
@@ -41,7 +42,6 @@
4142
},
4243
"dependencies": {
4344
"@microsoft/fast-colors": "^5.3.1",
44-
"@microsoft/fast-components": "^2.30.6",
4545
"@microsoft/fast-element": "^1.12.0",
4646
"@microsoft/fast-foundation": "^2.49.4",
4747
"@microsoft/fast-web-utilities": "^5.4.1"
@@ -55,7 +55,6 @@
5555
"@playwright/test": "^1.35.1",
5656
"@rollup/plugin-commonjs": "^17.1.0",
5757
"@rollup/plugin-node-resolve": "^11.2.0",
58-
"@rollup/plugin-typescript": "^8.2.0",
5958
"@storybook/addon-a11y": "^7.5.3",
6059
"@storybook/addon-actions": "^7.5.3",
6160
"@storybook/addon-docs": "^7.5.3",
@@ -66,7 +65,13 @@
6665
"@storybook/html": "^7.5.3",
6766
"@storybook/html-webpack5": "^7.5.3",
6867
"@storybook/theming": "^7.5.3",
68+
"@types/chai": "^4.2.11",
69+
"@types/chai-spies": "^1.0.1",
6970
"@types/jest": "^29.0.0",
71+
"@types/karma": "^5.0.0",
72+
"@types/mocha": "^8.2.0",
73+
"@types/node": "^18.0.0",
74+
"@types/webpack-env": "^1.15.2",
7075
"@typescript-eslint/eslint-plugin": "^5.60.1",
7176
"eslint": "^8.43.0",
7277
"eslint-config-prettier": "^8.8.0",
@@ -84,6 +89,7 @@
8489
"rollup-plugin-filesize": "^9.1.1",
8590
"rollup-plugin-terser": "^7.0.2",
8691
"rollup-plugin-transform-tagged-template": "0.0.3",
92+
"rollup-plugin-typescript2": "^0.27.0",
8793
"storybook": "^7.5.3",
8894
"ts-jest": "^29.1.0",
8995
"ts-loader": "^9.4.3",

packages/components/rollup.config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import commonjs from '@rollup/plugin-commonjs';
33
import filesize from 'rollup-plugin-filesize';
44
import { nodeResolve } from '@rollup/plugin-node-resolve';
55
import transformTaggedTemplate from 'rollup-plugin-transform-tagged-template';
6-
import typescript from '@rollup/plugin-typescript';
6+
import typescript from "rollup-plugin-typescript2";
77
import { terser } from 'rollup-plugin-terser';
88
import del from 'rollup-plugin-delete';
99

@@ -17,6 +17,15 @@ export default [
1717
{
1818
context: 'this',
1919
input: 'src/index-rollup.ts',
20+
onwarn(warning, warn) {
21+
// The IIFE export doesn't have a namespace since component exports
22+
// are expected to be top-level objects
23+
if (warning.code === "MISSING_NAME_OPTION_FOR_IIFE_EXPORT") {
24+
return;
25+
}
26+
27+
warn(warning);
28+
},
2029
output: [
2130
{
2231
file: 'dist/toolkit.js',
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function importAll(r: __WebpackModuleApi.RequireContext): void {
2+
r.keys().forEach(r);
3+
}
4+
5+
// Explicitly add to browser test
6+
importAll(require.context("../", true, /\.spec\.js$/));
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* eslint-disable */
2+
if (window.document && !window.document.createRange) {
3+
window.document.createRange = () => ({
4+
setStart: () => {},
5+
setEnd: () => {},
6+
// @ts-ignore
7+
commonAncestorContainer: {
8+
nodeName: "BODY",
9+
ownerDocument: document,
10+
},
11+
});
12+
}

packages/components/src/accordion-item/index.ts

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// Distributed under the terms of the Modified BSD License.
33

44
import {
5-
AccordionItem,
6-
AccordionItemOptions,
7-
accordionItemTemplate as template
5+
AccordionItem,
6+
AccordionItemOptions,
7+
accordionItemTemplate as template
88
} from '@microsoft/fast-foundation';
99
import { accordionItemStyles as styles } from './accordion-item.styles';
1010

@@ -18,39 +18,37 @@ import { accordionItemStyles as styles } from './accordion-item.styles';
1818
* Generates HTML Element: `<jp-accordion-item>`
1919
*/
2020
export const jpAccordionItem = AccordionItem.compose<AccordionItemOptions>({
21-
baseName: 'accordion-item',
22-
template,
23-
styles,
24-
collapsedIcon: /* html */ `
25-
<svg
26-
width="20"
27-
height="20"
28-
viewBox="0 0 16 16"
29-
xmlns="http://www.w3.org/2000/svg"
30-
class="expand-collapse-glyph"
31-
>
32-
<path
33-
fill-rule="evenodd"
34-
clip-rule="evenodd"
35-
d="M5.00001 12.3263C5.00124 12.5147 5.05566 12.699 5.15699 12.8578C5.25831 13.0167 5.40243 13.1437 5.57273 13.2242C5.74304 13.3047 5.9326 13.3354 6.11959 13.3128C6.30659 13.2902 6.4834 13.2152 6.62967 13.0965L10.8988 8.83532C11.0739 8.69473 11.2153 8.51658 11.3124 8.31402C11.4096 8.11146 11.46 7.88966 11.46 7.66499C11.46 7.44033 11.4096 7.21853 11.3124 7.01597C11.2153 6.81341 11.0739 6.63526 10.8988 6.49467L6.62967 2.22347C6.48274 2.10422 6.30501 2.02912 6.11712 2.00691C5.92923 1.9847 5.73889 2.01628 5.56823 2.09799C5.39757 2.17969 5.25358 2.30817 5.153 2.46849C5.05241 2.62882 4.99936 2.8144 5.00001 3.00369V12.3263Z"
36-
/>
37-
</svg>
21+
baseName: 'accordion-item',
22+
template,
23+
styles,
24+
collapsedIcon: /* html */ `
25+
<svg
26+
width="20"
27+
height="20"
28+
viewBox="0 0 16 16"
29+
xmlns="http://www.w3.org/2000/svg"
30+
>
31+
<path
32+
fill-rule="evenodd"
33+
clip-rule="evenodd"
34+
d="M5.00001 12.3263C5.00124 12.5147 5.05566 12.699 5.15699 12.8578C5.25831 13.0167 5.40243 13.1437 5.57273 13.2242C5.74304 13.3047 5.9326 13.3354 6.11959 13.3128C6.30659 13.2902 6.4834 13.2152 6.62967 13.0965L10.8988 8.83532C11.0739 8.69473 11.2153 8.51658 11.3124 8.31402C11.4096 8.11146 11.46 7.88966 11.46 7.66499C11.46 7.44033 11.4096 7.21853 11.3124 7.01597C11.2153 6.81341 11.0739 6.63526 10.8988 6.49467L6.62967 2.22347C6.48274 2.10422 6.30501 2.02912 6.11712 2.00691C5.92923 1.9847 5.73889 2.01628 5.56823 2.09799C5.39757 2.17969 5.25358 2.30817 5.153 2.46849C5.05241 2.62882 4.99936 2.8144 5.00001 3.00369V12.3263Z"
35+
/>
36+
</svg>
3837
`,
39-
expandedIcon: /* html */ `
40-
<svg
41-
width="20"
42-
height="20"
43-
viewBox="0 0 16 16"
44-
xmlns="http://www.w3.org/2000/svg"
45-
class="expand-collapse-glyph"
46-
>
47-
<path
48-
fill-rule="evenodd"
49-
clip-rule="evenodd"
50-
transform="rotate(90,8,8)"
38+
expandedIcon: /* html */ `
39+
<svg
40+
width="20"
41+
height="20"
42+
viewBox="0 0 16 16"
43+
xmlns="http://www.w3.org/2000/svg"
44+
>
45+
<path
46+
fill-rule="evenodd"
47+
clip-rule="evenodd"
48+
transform="rotate(90,8,8)"
5149
d="M5.00001 12.3263C5.00124 12.5147 5.05566 12.699 5.15699 12.8578C5.25831 13.0167 5.40243 13.1437 5.57273 13.2242C5.74304 13.3047 5.9326 13.3354 6.11959 13.3128C6.30659 13.2902 6.4834 13.2152 6.62967 13.0965L10.8988 8.83532C11.0739 8.69473 11.2153 8.51658 11.3124 8.31402C11.4096 8.11146 11.46 7.88966 11.46 7.66499C11.46 7.44033 11.4096 7.21853 11.3124 7.01597C11.2153 6.81341 11.0739 6.63526 10.8988 6.49467L6.62967 2.22347C6.48274 2.10422 6.30501 2.02912 6.11712 2.00691C5.92923 1.9847 5.73889 2.01628 5.56823 2.09799C5.39757 2.17969 5.25358 2.30817 5.153 2.46849C5.05241 2.62882 4.99936 2.8144 5.00001 3.00369V12.3263Z"
52-
/>
53-
</svg>
50+
/>
51+
</svg>
5452
`
5553
});
5654

packages/components/src/accordion/accordion.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { HtmlRenderer, Meta, StoryObj, StoryFn } from '@storybook/html';
44
import { setTheme } from '../utilities/storybook';
55

66
export default {
7-
title: 'Components/Accordion',
7+
title: 'Components/Accordion',
88

99
parameters: {
1010
controls: {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { css, ElementStyles } from "@microsoft/fast-element";
2+
import { display, FoundationElementTemplate } from "@microsoft/fast-foundation";
3+
import {
4+
bodyFont,
5+
neutralForegroundRest,
6+
neutralStrokeDividerRest,
7+
strokeWidth,
8+
typeRampMinus1FontSize,
9+
typeRampMinus1LineHeight,
10+
} from "../design-tokens.js";
11+
12+
/**
13+
* Styles for Accordion
14+
* @public
15+
*/
16+
export const accordionStyles: FoundationElementTemplate<ElementStyles> = (
17+
context,
18+
definition
19+
) =>
20+
css`
21+
${display("flex")} :host {
22+
box-sizing: border-box;
23+
flex-direction: column;
24+
font-family: ${bodyFont};
25+
font-size: ${typeRampMinus1FontSize};
26+
line-height: ${typeRampMinus1LineHeight};
27+
color: ${neutralForegroundRest};
28+
border-top: calc(${strokeWidth} * 1px) solid ${neutralStrokeDividerRest};
29+
}
30+
`;

0 commit comments

Comments
 (0)