-
Notifications
You must be signed in to change notification settings - Fork 51
Showcase GTS conversion - ApplicationState #3175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zamoore
wants to merge
28
commits into
main
Choose a base branch
from
zamoore/HDS-5329/convert-application-state-page-to-gts
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
aeee071
converted all subsections
zamoore e5264e4
moved action to higher level component
zamoore 2cf2742
adding code fragments
zamoore 6cd9b7a
adding code fragments
zamoore 2d80fe9
fixing linting errors
zamoore ed60f1a
removing action usage
zamoore a98af18
fixing visual diffs
zamoore d383bef
added media variants
zamoore c9c70a5
removed additional toggle
zamoore 98df0e3
fixing type signatures
zamoore 9a5ff24
fix linting error
zamoore 6777374
running prettier
zamoore 46013c9
applying PR feedback from @dchyun
zamoore 0635988
applying PR feedback from @didoo
zamoore 34995b7
applying PR feedback from @didoo
zamoore 97bf5c9
condensing code fragments
zamoore c413989
combining code fragments
zamoore 3312a6d
fixing ts error
zamoore e992241
fixing showcase build
zamoore 441dae0
fixing percy diffs
zamoore 263bb08
removed route/controller code
zamoore d155b9c
returned missing images
zamoore aae10f0
fixing percy diff
zamoore 748b861
fix linting error
zamoore d1512ce
fixing percy diff
zamoore a83d634
fixing percy diff
zamoore 51adda6
fixing percy diff
zamoore 10b67c8
revert style change
zamoore File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
.../app/components/page-components/application-state/code-fragments/with-action-variants.gts
This file contains hidden or 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,64 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
import { HdsApplicationState } from '@hashicorp/design-system-components/components'; | ||
|
||
import type { TemplateOnlyComponent } from '@ember/component/template-only'; | ||
import type { HdsApplicationStateSignature } from '@hashicorp/design-system-components/components/hds/application-state/index'; | ||
|
||
export interface CodeFragmentWithActionVariantsSignature { | ||
Args: { | ||
align: HdsApplicationStateSignature['Args']['align']; | ||
hasDropdown?: boolean; | ||
hasPrimaryAction?: boolean; | ||
hasSecondaryAction?: boolean; | ||
hasStandaloneLink?: boolean; | ||
}; | ||
Element: HdsApplicationStateSignature['Element']; | ||
} | ||
|
||
const CodeFragmentWithActionVariants: TemplateOnlyComponent<CodeFragmentWithActionVariantsSignature> = | ||
<template> | ||
<HdsApplicationState @align={{@align}} as |A|> | ||
<A.Header | ||
@title="An error has occurred" | ||
@icon="alert-circle" | ||
@errorCode="404" | ||
/> | ||
<A.Body | ||
@text="Sorry, an unexpected error has occurred. Please try again later or contact support for assistance." | ||
/> | ||
<A.Footer as |F|> | ||
{{#if @hasPrimaryAction}} | ||
<F.Button @color="primary" @text="Primary action" /> | ||
{{/if}} | ||
|
||
{{#if @hasSecondaryAction}} | ||
<F.Button @color="secondary" @text="Secondary action" /> | ||
{{/if}} | ||
|
||
{{#if @hasDropdown}} | ||
<F.Dropdown @listPosition="bottom-right" as |dd|> | ||
<dd.ToggleButton @text="Choose an option" /> | ||
<dd.Title @text="Categories" /> | ||
<dd.Interactive @href="#">Documentation</dd.Interactive> | ||
<dd.Interactive @href="#">Tutorials</dd.Interactive> | ||
<dd.Interactive @href="#">Changelogs</dd.Interactive> | ||
</F.Dropdown> | ||
{{/if}} | ||
|
||
{{#if @hasStandaloneLink}} | ||
<F.LinkStandalone | ||
@icon="docs-link" | ||
@text="Learn more" | ||
@iconPosition="trailing" | ||
@href="#" | ||
/> | ||
{{/if}} | ||
</A.Footer> | ||
</HdsApplicationState> | ||
</template>; | ||
|
||
export default CodeFragmentWithActionVariants; |
108 changes: 108 additions & 0 deletions
108
...se/app/components/page-components/application-state/code-fragments/with-error-content.gts
This file contains hidden or 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,108 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
import Component from '@glimmer/component'; | ||
import { eq } from 'ember-truth-helpers'; | ||
|
||
import { | ||
HdsApplicationState, | ||
HdsIcon, | ||
HdsIconTile, | ||
} from '@hashicorp/design-system-components/components'; | ||
|
||
import ShwPlaceholder from 'showcase/components/shw/placeholder'; | ||
|
||
import type { HdsApplicationStateSignature } from '@hashicorp/design-system-components/components/hds/application-state/index'; | ||
import type { HdsApplicationStateHeaderSignature } from '@hashicorp/design-system-components/components/hds/application-state/header'; | ||
|
||
enum CodeFragmentWithErrorContentActionsValues { | ||
Primary = 'primary', | ||
Secondary = 'secondary', | ||
StandaloneLink = 'standaloneLink', | ||
} | ||
|
||
type CodeFragmentWithErrorContentActions = | ||
`${CodeFragmentWithErrorContentActionsValues}`; | ||
|
||
enum CodeFragmentWithErrorContentMediaValues { | ||
Icon = 'icon', | ||
IconTile = 'icon-tile', | ||
Image = 'image', | ||
Generic = 'generic', | ||
} | ||
|
||
type CodeFragmentWithErrorContentMedia = | ||
`${CodeFragmentWithErrorContentMediaValues}`; | ||
|
||
interface CodeFragmentWithErrorContentSignature { | ||
Args: { | ||
actions?: Array<CodeFragmentWithErrorContentActions>; | ||
align?: HdsApplicationStateSignature['Args']['align']; | ||
bodyText?: string; | ||
hasErrorCode?: boolean; | ||
media?: CodeFragmentWithErrorContentMedia; | ||
icon?: HdsApplicationStateHeaderSignature['Args']['icon']; | ||
titleTag?: HdsApplicationStateHeaderSignature['Args']['titleTag']; | ||
titleText?: string; | ||
}; | ||
Element: HdsApplicationStateSignature['Element']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [note] technically this is not necessary, since we're not spreading the |
||
} | ||
|
||
export default class CodeFragmentWithErrorContent extends Component<CodeFragmentWithErrorContentSignature> { | ||
get titleText() { | ||
return this.args.titleText ?? 'An error has occurred'; | ||
} | ||
|
||
get bodyText() { | ||
return ( | ||
this.args.bodyText ?? | ||
'Sorry, an unexpected error has occurred. Please try again later or contact support for assistance.' | ||
); | ||
} | ||
|
||
includesAction = (action: CodeFragmentWithErrorContentActions) => { | ||
return this.args.actions?.includes(action); | ||
}; | ||
|
||
<template> | ||
<HdsApplicationState @align={{@align}} as |A|> | ||
{{#if @media}} | ||
<A.Media> | ||
{{#if (eq @media "icon")}} | ||
<HdsIcon @name="channel" @size="24" /> | ||
{{else if (eq @media "icon-tile")}} | ||
<HdsIconTile @logo="terraform" @size="large" /> | ||
{{else if (eq @media "image")}} | ||
<img | ||
src="/assets/images/cat-banner.png" | ||
alt="3 cats wearing old-fashioned formal wear" | ||
class="shw-component-application-state-banner" | ||
/> | ||
{{else if (eq @media "generic")}} | ||
<ShwPlaceholder @text="media" @width="80" @height="80" /> | ||
{{/if}} | ||
</A.Media> | ||
{{/if}} | ||
<A.Header | ||
@title={{this.titleText}} | ||
@titleTag={{@titleTag}} | ||
@icon={{@icon}} | ||
@errorCode={{if @hasErrorCode "404"}} | ||
/> | ||
<A.Body @text={{this.bodyText}} /> | ||
<A.Footer as |F|> | ||
{{#if (this.includesAction "primary")}} | ||
<F.Button @color="primary" @text="Primary action" /> | ||
{{/if}} | ||
{{#if (this.includesAction "secondary")}} | ||
<F.Button @color="secondary" @text="Secondary action" /> | ||
{{/if}} | ||
{{#if (this.includesAction "standaloneLink")}} | ||
<F.LinkStandalone @icon="arrow-left" @text="Go back" @href="/" /> | ||
{{/if}} | ||
</A.Footer> | ||
</HdsApplicationState> | ||
</template> | ||
} |
26 changes: 26 additions & 0 deletions
26
.../app/components/page-components/application-state/code-fragments/with-generic-content.gts
This file contains hidden or 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,26 @@ | ||||||||||||||
/** | ||||||||||||||
* Copyright (c) HashiCorp, Inc. | ||||||||||||||
* SPDX-License-Identifier: MPL-2.0 | ||||||||||||||
*/ | ||||||||||||||
|
||||||||||||||
import { HdsApplicationState } from '@hashicorp/design-system-components/components'; | ||||||||||||||
|
||||||||||||||
import type { TemplateOnlyComponent } from '@ember/component/template-only'; | ||||||||||||||
import type { HdsApplicationStateSignature } from '@hashicorp/design-system-components/components/hds/application-state/index'; | ||||||||||||||
|
||||||||||||||
interface CodeFragmentWithGenericContentSignature { | ||||||||||||||
Element: HdsApplicationStateSignature['Element']; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
const CodeFragmentWithGenericContent: TemplateOnlyComponent<CodeFragmentWithGenericContentSignature> = | ||||||||||||||
Comment on lines
+11
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
<template> | ||||||||||||||
<HdsApplicationState @align="center" as |A|> | ||||||||||||||
<A.Header @title="No stacks" /> | ||||||||||||||
<A.Body @text="No stacks to show in this project." /> | ||||||||||||||
<A.Footer as |F|> | ||||||||||||||
<F.Button @color="primary" @text="Create stack" /> | ||||||||||||||
</A.Footer> | ||||||||||||||
</HdsApplicationState> | ||||||||||||||
</template>; | ||||||||||||||
|
||||||||||||||
export default CodeFragmentWithGenericContent; |
59 changes: 59 additions & 0 deletions
59
showcase/app/components/page-components/application-state/index.gts
This file contains hidden or 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,59 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { pageTitle } from 'ember-page-title'; | ||
|
||
import ShwTextH1 from 'showcase/components/shw/text/h1'; | ||
|
||
import SubSectionAlignment from 'showcase/components/page-components/application-state/sub-sections/alignment'; | ||
import SubSectionContent from 'showcase/components/page-components/application-state/sub-sections/content'; | ||
import SubSectionContainer from 'showcase/components/page-components/application-state/sub-sections/container'; | ||
import SubSectionResponsiveness from 'showcase/components/page-components/application-state/sub-sections/responsiveness'; | ||
import SubSectionWithMedia from 'showcase/components/page-components/application-state/sub-sections/with-media'; | ||
|
||
export default class ApplicationStateIndex extends Component { | ||
@tracked showHighlight = false; | ||
|
||
toggleHighlight = () => { | ||
this.showHighlight = !this.showHighlight; | ||
}; | ||
didoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<template> | ||
{{pageTitle "ApplicationState Component"}} | ||
|
||
<ShwTextH1>ApplicationState</ShwTextH1> | ||
|
||
<section | ||
data-test-percy | ||
class="{{if | ||
this.showHighlight | ||
'shw-component-application-state-layout-highlight' | ||
}}" | ||
> | ||
<SubSectionContent | ||
@showHighlight={{this.showHighlight}} | ||
@toggleHighlight={{this.toggleHighlight}} | ||
/> | ||
<SubSectionAlignment | ||
@showHighlight={{this.showHighlight}} | ||
@toggleHighlight={{this.toggleHighlight}} | ||
/> | ||
<SubSectionWithMedia | ||
@showHighlight={{this.showHighlight}} | ||
@toggleHighlight={{this.toggleHighlight}} | ||
/> | ||
<SubSectionResponsiveness | ||
@showHighlight={{this.showHighlight}} | ||
@toggleHighlight={{this.toggleHighlight}} | ||
/> | ||
<SubSectionContainer | ||
@showHighlight={{this.showHighlight}} | ||
@toggleHighlight={{this.toggleHighlight}} | ||
/> | ||
</section> | ||
</template> | ||
} |
96 changes: 96 additions & 0 deletions
96
showcase/app/components/page-components/application-state/sub-sections/alignment.gts
This file contains hidden or 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,96 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
import { on } from '@ember/modifier'; | ||
import { capitalize } from '@ember/string'; | ||
import { eq } from 'ember-truth-helpers'; | ||
|
||
import ShwFlex from 'showcase/components/shw/flex'; | ||
import ShwTextH2 from 'showcase/components/shw/text/h2'; | ||
import ShwDivider from 'showcase/components/shw/divider'; | ||
import { ALIGNS } from '@hashicorp/design-system-components/components/hds/application-state/index'; | ||
|
||
import CodeFragmentWithActionVariants from '../code-fragments/with-action-variants'; | ||
|
||
import type { TemplateOnlyComponent } from '@ember/component/template-only'; | ||
|
||
export interface SubSectionAlignmentSignature { | ||
Args: { | ||
showHighlight: boolean; | ||
toggleHighlight: () => void; | ||
}; | ||
} | ||
|
||
const SubSectionAlignment: TemplateOnlyComponent<SubSectionAlignmentSignature> = | ||
<template> | ||
<ShwTextH2>Alignment</ShwTextH2> | ||
|
||
<button | ||
type="button" | ||
class="shw-component-application-state-button-highlight" | ||
{{on "click" @toggleHighlight}} | ||
> | ||
{{if @showHighlight "Hide" "Show"}} | ||
layout highlight | ||
</button> | ||
|
||
<ShwFlex @direction="row" @gap="4rem" as |SF|> | ||
{{#each ALIGNS as |align|}} | ||
<SF.Item | ||
@label="{{capitalize align}} aligned {{if | ||
(eq align 'left') | ||
' (default)' | ||
}}" | ||
> | ||
<CodeFragmentWithActionVariants | ||
@align={{align}} | ||
@hasStandaloneLink={{true}} | ||
/> | ||
</SF.Item> | ||
{{/each}} | ||
{{#each ALIGNS as |align|}} | ||
<SF.Item @label="Two actions / {{align}} aligned"> | ||
<CodeFragmentWithActionVariants | ||
@align={{align}} | ||
@hasPrimaryAction={{true}} | ||
@hasStandaloneLink={{true}} | ||
/> | ||
</SF.Item> | ||
{{/each}} | ||
{{#each ALIGNS as |align|}} | ||
<SF.Item @label="Three actions / {{align}} aligned"> | ||
<CodeFragmentWithActionVariants | ||
@align={{align}} | ||
@hasPrimaryAction={{true}} | ||
@hasSecondaryAction={{true}} | ||
@hasStandaloneLink={{true}} | ||
/> | ||
</SF.Item> | ||
{{/each}} | ||
{{#each ALIGNS as |align|}} | ||
<SF.Item @label="Two actions (1 dropdown) / {{align}} aligned"> | ||
<CodeFragmentWithActionVariants | ||
@align={{align}} | ||
@hasDropdown={{true}} | ||
@hasPrimaryAction={{true}} | ||
/> | ||
</SF.Item> | ||
{{/each}} | ||
{{#each ALIGNS as |align|}} | ||
<SF.Item @label="Three actions (1 dropdown) / {{align}} aligned"> | ||
<CodeFragmentWithActionVariants | ||
@align={{align}} | ||
@hasDropdown={{true}} | ||
@hasPrimaryAction={{true}} | ||
@hasStandaloneLink={{true}} | ||
/> | ||
</SF.Item> | ||
{{/each}} | ||
</ShwFlex> | ||
|
||
<ShwDivider /> | ||
</template>; | ||
|
||
export default SubSectionAlignment; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[note] technically this is not necessary, since we're not spreading the ...attributes operator