-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the switch foundation component (#55)
# Pull Request ## π Description <!--- Provide some background and a description of your work. --> Adds the switch foundation component. ### π« Issues <!--- List and link relevant issues here using the keyword "closes" if this PR will close an issue, eg. closes #411 --> Continues work on #31 ## β Checklist ### General <!--- Review the list and put an x in the boxes that apply. --> - [x] I have added tests for my changes. - [x] I have tested my changes. - [x] I have updated the project documentation to reflect my changes. ## β Next Steps <!--- If there is relevant follow-up work to this PR, please list any existing issues or provide brief descriptions of what you would like to do next. --> - Continue work on #31
- Loading branch information
Showing
16 changed files
with
503 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@microsoft-fast-cli-e2ef1965-526d-441f-8e5e-3c1fac5824cf.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "none", | ||
"comment": "Added the switch foundation component", | ||
"packageName": "@microsoft/fast-cli", | ||
"email": "7559015+janechu@users.noreply.github.com", | ||
"dependentChangeType": "none" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ export const availableTemplates = [ | |
"progress", | ||
"progress-ring", | ||
"search", | ||
"switch", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Description | ||
|
||
This template is used as a switch component template from which a user can modify without having to do the initial scaffolding. |
33 changes: 33 additions & 0 deletions
33
packages/fast-cli/src/components/switch/template.pw.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import { execSync } from "child_process"; | ||
import { | ||
expectedGeneratedComponentTemplateFiles, | ||
setupComponent, | ||
teardown, | ||
getGeneratedComponentFiles, | ||
getTempDir, | ||
getTempComponentDir, | ||
} from "../../test/helpers.js"; | ||
|
||
const uuid: string = "switch"; | ||
const tempDir: string = getTempDir(uuid); | ||
const tempComponentDir: string = getTempComponentDir(uuid); | ||
|
||
test.describe(`CLI add-foundation-component ${uuid}`, () => { | ||
test.beforeAll(() => { | ||
setupComponent(uuid, tempDir, tempComponentDir); | ||
}); | ||
test.afterAll(() => { | ||
teardown(tempDir, tempComponentDir); | ||
}); | ||
test("should copy files from the template", () => { | ||
expect(getGeneratedComponentFiles(tempDir)).toEqual(expectedGeneratedComponentTemplateFiles); | ||
}); | ||
test("should be able to run the build", () => { | ||
expect( | ||
() => { | ||
execSync(`cd ${tempDir} && npm run build`); | ||
} | ||
).not.toThrow(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { ComponentTemplateConfig } from "../../../utilities/template"; | ||
|
||
export default (config: ComponentTemplateConfig): string => ` | ||
# ${config.className} | ||
An implementation of a [switch](https://w3c.github.io/aria/#switch) as a form-connected web-component. | ||
For more information on the building blocks used to create this component, please refer to https://www.fast.design/docs/components/switch`; |
14 changes: 14 additions & 0 deletions
14
packages/fast-cli/src/components/switch/template/component.definition.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { ComponentTemplateConfig } from "../../../utilities/template"; | ||
|
||
export default (config: ComponentTemplateConfig): string => | ||
`import { template } from "./${config.tagName}.template.js"; | ||
import { styles } from "./${config.tagName}.styles.js"; | ||
export const definition = { | ||
baseName: "${config.tagName}", | ||
template, | ||
styles, | ||
switch: /* html */ \` | ||
<span class="checked-indicator" part="checked-indicator"></span> | ||
\`, | ||
};`; |
25 changes: 25 additions & 0 deletions
25
packages/fast-cli/src/components/switch/template/component.pw.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { ComponentTemplateConfig } from "../../../utilities/template"; | ||
|
||
export default (config: ComponentTemplateConfig): string => ` | ||
import { expect, test } from "@playwright/test"; | ||
import { fixtureURL } from "@microsoft/fast-cli/dist/esm/utilities/playwright.js"; | ||
test.describe("${config.tagName}", () => { | ||
const fixture = fixtureURL("${config.tagName}"); | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(fixture); | ||
}); | ||
test("should load the fixture URL", async ({ page }) => { | ||
const pageUrl = page.url(); | ||
expect(pageUrl).toBe(\`http://localhost:3000/\${fixture}\`); | ||
}); | ||
test("should contain the component in the URL", async ({ page }) => { | ||
const element = page.locator("${config.tagName}"); | ||
await expect(element).not.toBeNull(); | ||
}); | ||
}); | ||
` |
12 changes: 12 additions & 0 deletions
12
packages/fast-cli/src/components/switch/template/component.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { ComponentTemplateConfig } from "../../../utilities/template"; | ||
|
||
export default (config: ComponentTemplateConfig): string => ` | ||
import Template from "./fixtures/base.html"; | ||
import "./define.js"; | ||
export default { | ||
title: "${config.tagName}", | ||
}; | ||
export const ${config.className} = () => Template; | ||
`; |
Oops, something went wrong.