Skip to content
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

feat: New gcds-notice component #627

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

ethanWallace
Copy link
Collaborator

@ethanWallace ethanWallace commented Aug 27, 2024

Summary | Résumé

The notice is a prominent message to draw attention to important information or change.

<gcds-notice
  type=""
  notice-title=""
>
  <slot></slot>
</gcds-notice>

Requires tokens from cds-snc/gcds-tokens#330. (Merged and installed)

Copy link
Collaborator

@melaniebmn melaniebmn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments with changes.

packages/web/src/index.html Outdated Show resolved Hide resolved
packages/web/src/index.html Outdated Show resolved Hide resolved
packages/web/src/components/gcds-notice/gcds-notice.tsx Outdated Show resolved Hide resolved
packages/web/src/components/gcds-notice/gcds-notice.tsx Outdated Show resolved Hide resolved
packages/web/src/components/gcds-notice/gcds-notice.css Outdated Show resolved Hide resolved
packages/web/src/components/gcds-notice/gcds-notice.css Outdated Show resolved Hide resolved
packages/web/src/components/gcds-notice/gcds-notice.css Outdated Show resolved Hide resolved
packages/web/src/components/gcds-notice/gcds-notice.css Outdated Show resolved Hide resolved
@@ -0,0 +1,35 @@
# gcds-alert
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, do you know why this says gcds-alert?

Copy link
Collaborator Author

@ethanWallace ethanWallace Sep 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied over the alert files as a base and just missed replacing this one thing 😄

*/

/**
* Defines notice role.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, could we change this to

Suggested change
* Defines notice role.
* Set notice role.

I've mostly seen us use "Set" here but open to other options

}

/**
* Defines the notice title.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Suggested change
* Defines the notice title.
* Set the notice title.

<strong class="notice__type">
{i18n[lang]['type'][type]}
</strong>
{/* Hidden colon to provide pause between caption and heading text for AT */}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does AT mean accessibility tree?

Suggested change
{/* Hidden colon to provide pause between caption and heading text for AT */}
{/* Hidden colon to provide pause between caption and heading text for accessibility tree */}

import { newSpecPage } from '@stencil/core/testing';
import { GcdsNotice } from '../gcds-notice';

describe('gcds-alert', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a typo? 😄

Suggested change
describe('gcds-alert', () => {
describe('gcds-notice', () => {

Copy link
Collaborator

@melaniebmn melaniebmn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making all the changes! Looks good to me, I'll hold off on approving until we hear back about the DTO alignment.

Copy link
Contributor

@duboisp duboisp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I quickly went through this PR and I would like to propose the following 2 additions:

  • Add a property to configure the heading level for the notice. It is not always at level 2.
  • Add a property to configure the text representing the type of alert. Sometime a web author might want to use alternate words to represent the type of notice for better integration into existing web content.

Thought?

<Host>
{this.validateRequiredProps() && (
<section class={`gcds-notice notice--type-${type}`}>
<gcds-heading tag="h2" marginTop="0" class="notice__heading">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of [tag=h2] is a good default but there can be some situation where a web author would like to set if for a different heading level.

<section class={`gcds-notice notice--type-${type}`}>
<gcds-heading tag="h2" marginTop="0" class="notice__heading">
<strong class="notice__type">
{i18n[lang]['type'][type]}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about if the web author want to use alternative words which do also provide a sense of the type of notice?

Take for example an impromptu office closure, IMHO the following notice wont be desirable as there is not necessary means an immediate danger for the public:

Danger: Office closure
The office X was closed for the day due to Y situation.
image

May be they it will be preferable to have something more contextualized which should be rendered as a danger notice type like:

Unplanned: Office closure
The office X was closed for the day due to Y situation.
image

I would like to propose to add a new property to allow the web author to customization the text conveying the importance level of the notice. If not provided, it can fallback on this default.

Thought?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the input! We have made the decision to change the design of the notice component to back to the design already available from canada.ca (with the icon). We just haven't had a chance to update this PR yet with those design changes

Copy link
Collaborator

@daine daine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one small suggestion for the code to display the icons. I know we don't have the tokens yet so I'll review again once we have that in place. At the moment I don't see the lines on the icon, I'm guessing we need the tokens for that

Comment on lines 114 to 124
name={
type === 'danger'
? 'exclamation-circle'
: type === 'info'
? 'info-circle'
: type === 'success'
? 'check-circle'
: type === 'warning'
? 'exclamation-triangle'
: null
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could change this to a lookup instead of multiple if-else to optimize it?
Something like:

let iconType = null;
let iconTypes = {
  'danger': 'exclamation-circle',
  'info': 'info-circle',
  'success': 'check-circle',
  'warning': 'exclamation-triangle'
}

and then:

name={iconTypes[type]}

@ethanWallace
Copy link
Collaborator Author

I have one small suggestion for the code to display the icons. I know we don't have the tokens yet so I'll review again once we have that in place. At the moment I don't see the lines on the icon, I'm guessing we need the tokens for that

@daine Would you be able to test with the tokens package linked? It helps identify if a mistake snuck through in the token package before it is published

Copy link
Collaborator

@melaniebmn melaniebmn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants