-
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.
# Pull Request ## π Description <!--- Provide some background and a description of your work. --> Adds the dialog 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 adding foundation components
- Loading branch information
Showing
15 changed files
with
219 additions
and
1 deletion.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@microsoft-fast-cli-99144116-1d74-4ca3-a511-893a70c2171e.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 dialog component", | ||
"packageName": "@microsoft/fast-cli", | ||
"email": "7559015+janechu@users.noreply.github.com", | ||
"dependentChangeType": "none" | ||
} |
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
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 dialog component template from which a user can modify without having to do the initial scaffolding. |
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 @@ | ||
import type { ComponentTemplateConfig } from "../../../utilities/template"; | ||
|
||
export default (config: ComponentTemplateConfig): string => ` | ||
# ${config.className} | ||
A web component implementation of a [dialog](https://w3c.github.io/aria-practices/#dialog_modal). | ||
For more information on the building blocks used to create this component, please refer to https://www.fast.design/docs/components/card`; |
11 changes: 11 additions & 0 deletions
11
packages/fast-cli/src/components/dialog/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,11 @@ | ||
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, | ||
}`; |
21 changes: 21 additions & 0 deletions
21
packages/fast-cli/src/components/dialog/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,21 @@ | ||
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(); | ||
}); | ||
}); | ||
` |
11 changes: 11 additions & 0 deletions
11
packages/fast-cli/src/components/dialog/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,11 @@ | ||
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; | ||
`; |
56 changes: 56 additions & 0 deletions
56
packages/fast-cli/src/components/dialog/template/component.styles.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,56 @@ | ||
import type { ComponentTemplateConfig } from "../../../utilities/template"; | ||
|
||
export default (config: ComponentTemplateConfig): string => | ||
`import { css, ElementStyles } from "@microsoft/fast-element"; | ||
import type { FoundationElementTemplate } from "@microsoft/fast-foundation"; | ||
import { controlCornerRadius, elevation, fillColor, strokeWidth } from "@microsoft/adaptive-ui"; | ||
/** | ||
* Styles for ${config.className} | ||
* @public | ||
*/ | ||
export const styles: FoundationElementTemplate<ElementStyles> = ( | ||
context, | ||
definition | ||
) => | ||
css\` | ||
:host([hidden]) { | ||
display: none; | ||
} | ||
:host { | ||
--elevation: 14; | ||
--${config.tagName}-height: 480px; | ||
--${config.tagName}-width: 640px; | ||
display: block; | ||
} | ||
.overlay { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background: rgba(0, 0, 0, 0.3); | ||
touch-action: none; | ||
} | ||
.positioning-region { | ||
display: flex; | ||
justify-content: center; | ||
position: fixed; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
overflow: auto; | ||
} | ||
.control { | ||
\${elevation} | ||
margin-top: auto; | ||
margin-bottom: auto; | ||
width: var(--${config.tagName}-width); | ||
height: var(--${config.tagName}-height); | ||
background-color: \${fillColor}; | ||
z-index: 1; | ||
border-radius: calc(\${controlCornerRadius} * 1px); | ||
border: calc(\${strokeWidth} * 1px) solid transparent; | ||
} | ||
\`;`; |
12 changes: 12 additions & 0 deletions
12
packages/fast-cli/src/components/dialog/template/component.template.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 { Dialog, dialogTemplate, FoundationElementTemplate } from "@microsoft/fast-foundation"; | ||
import type { ViewTemplate } from "@microsoft/fast-element"; | ||
/** | ||
* The template for ${config.className} component. | ||
* @public | ||
*/ | ||
export const template: FoundationElementTemplate<ViewTemplate<Dialog>> = dialogTemplate; | ||
`; |
8 changes: 8 additions & 0 deletions
8
packages/fast-cli/src/components/dialog/template/component.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,8 @@ | ||
import type { ComponentTemplateConfig } from "../../../utilities/template"; | ||
|
||
export default (config: ComponentTemplateConfig): string => | ||
`import { Dialog } from "@microsoft/fast-foundation"; | ||
/** | ||
* A class derived from the Dialog foundation component | ||
*/ | ||
export class ${config.className} extends Dialog {};` |
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 @@ | ||
import type { ComponentTemplateConfig } from "../../../utilities/template"; | ||
|
||
export default (config: ComponentTemplateConfig): string => | ||
`import { ${config.className} } from "./${config.tagName}.js"; | ||
import { definition } from "./${config.tagName}.definition.js"; | ||
${config.className}.compose(definition);`; |
8 changes: 8 additions & 0 deletions
8
packages/fast-cli/src/components/dialog/template/fast.add-component.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,8 @@ | ||
{ | ||
"packageJson": { | ||
"dependencies": { | ||
"@microsoft/adaptive-ui": "../adaptive-ui", | ||
"@microsoft/fast-foundation": "^2.46.2" | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/fast-cli/src/components/dialog/template/fixture.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,20 @@ | ||
import type { ComponentTemplateConfig } from "../../../utilities/template"; | ||
|
||
export default (config: ComponentTemplateConfig): string => | ||
`<button id="button1"> | ||
Show ${config.className} | ||
</button> | ||
<p>tab queue detected automatically</p> | ||
<${config.tagName} | ||
id="dialog1" | ||
aria-label="Simple dialog" | ||
modal="true" | ||
trap-focus="true" | ||
hidden="true" | ||
> | ||
<h2>Dialog queue detected automatically</h2> | ||
<button>Button</button> | ||
<p>(esc to close)</p> | ||
</${config.tagName}> | ||
`; |
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,2 @@ | ||
// Import added to include the json file in the transpiled template | ||
import "./fast.add-component.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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export const availableTemplates = [ | ||
"badge", | ||
"blank" | ||
"blank", | ||
"dialog" | ||
] |