Skip to content

Commit

Permalink
feat: New gcds-notice component (#627)
Browse files Browse the repository at this point in the history
* First commit: new gcds-notice component

* gcds-notice stories

* gcds-notice spec and e2e tests

* fix CSS + format index.html

* Storybook fixes + upodate notice to use section

* Update to new tokens package version

* PR feedback: Notice formatting + clean up

* Remove unused line of CSS

* Add missing lang attribute in storybook

* PR feedback: fix typos

* First version of icon notice

* Update notice component to use icon instead of text label

* Update spec unit tests

* Update icon selection method

* Update tokens package

* PR feedback

* Add new notice-title-tag property

* Fix notice-title-tag comment

* Add invalid tag value test

* Modify internal heading margin-top to new spacing token value

* fix: notice heading spacing

* Update tokens package version
  • Loading branch information
ethanWallace authored Dec 11, 2024
1 parent 9ea1447 commit bb98233
Show file tree
Hide file tree
Showing 16 changed files with 1,071 additions and 1 deletion.
22 changes: 22 additions & 0 deletions packages/angular/src/lib/stencil-generated/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,28 @@ export declare interface GcdsNavLink extends Components.GcdsNavLink {
}


@ProxyCmp({
inputs: ['noticeTitle', 'noticeTitleTag', 'type']
})
@Component({
selector: 'gcds-notice',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['noticeTitle', 'noticeTitleTag', 'type'],
})
export class GcdsNotice {
protected el: HTMLElement;
constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
c.detach();
this.el = r.nativeElement;
}
}


export declare interface GcdsNotice extends Components.GcdsNotice {}


@ProxyCmp({
inputs: ['currentPage', 'display', 'label', 'nextHref', 'nextLabel', 'previousHref', 'previousLabel', 'totalPages', 'url'],
outputs: ['gcdsFocus', 'gcdsBlur', 'gcdsClick']
Expand Down
1 change: 1 addition & 0 deletions packages/angular/src/lib/stencil-generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const DIRECTIVES = [
d.GcdsLink,
d.GcdsNavGroup,
d.GcdsNavLink,
d.GcdsNotice,
d.GcdsPagination,
d.GcdsPhaseBanner,
d.GcdsRadioGroup,
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/components/stencil-generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const GcdsLangToggle = /*@__PURE__*/createReactComponent<JSX.GcdsLangTogg
export const GcdsLink = /*@__PURE__*/createReactComponent<JSX.GcdsLink, HTMLGcdsLinkElement>('gcds-link');
export const GcdsNavGroup = /*@__PURE__*/createReactComponent<JSX.GcdsNavGroup, HTMLGcdsNavGroupElement>('gcds-nav-group');
export const GcdsNavLink = /*@__PURE__*/createReactComponent<JSX.GcdsNavLink, HTMLGcdsNavLinkElement>('gcds-nav-link');
export const GcdsNotice = /*@__PURE__*/createReactComponent<JSX.GcdsNotice, HTMLGcdsNoticeElement>('gcds-notice');
export const GcdsPagination = /*@__PURE__*/createReactComponent<JSX.GcdsPagination, HTMLGcdsPaginationElement>('gcds-pagination');
export const GcdsPhaseBanner = /*@__PURE__*/createReactComponent<JSX.GcdsPhaseBanner, HTMLGcdsPhaseBannerElement>('gcds-phase-banner');
export const GcdsRadioGroup = /*@__PURE__*/createReactComponent<JSX.GcdsRadioGroup, HTMLGcdsRadioGroupElement>('gcds-radio-group');
Expand Down
7 changes: 7 additions & 0 deletions packages/vue/lib/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,13 @@ export const GcdsNavLink = /*@__PURE__*/ defineContainer<JSX.GcdsNavLink>('gcds-
]);


export const GcdsNotice = /*@__PURE__*/ defineContainer<JSX.GcdsNotice>('gcds-notice', undefined, [
'type',
'noticeTitle',
'noticeTitleTag'
]);


export const GcdsPagination = /*@__PURE__*/ defineContainer<JSX.GcdsPagination>('gcds-pagination', undefined, [
'display',
'label',
Expand Down
37 changes: 37 additions & 0 deletions packages/web/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,20 @@ export namespace Components {
*/
"href": string;
}
interface GcdsNotice {
/**
* Set the notice title.
*/
"noticeTitle": string;
/**
* Set notice title heading tag.
*/
"noticeTitleTag": 'h2' | 'h3' | 'h4' | 'h5';
/**
* Set notice type.
*/
"type": 'danger' | 'info' | 'success' | 'warning';
}
interface GcdsPagination {
/**
* List display - Current page number
Expand Down Expand Up @@ -1484,6 +1498,12 @@ declare global {
prototype: HTMLGcdsNavLinkElement;
new (): HTMLGcdsNavLinkElement;
};
interface HTMLGcdsNoticeElement extends Components.GcdsNotice, HTMLStencilElement {
}
var HTMLGcdsNoticeElement: {
prototype: HTMLGcdsNoticeElement;
new (): HTMLGcdsNoticeElement;
};
interface HTMLGcdsPaginationElementEventMap {
"gcdsFocus": void;
"gcdsBlur": void;
Expand Down Expand Up @@ -1669,6 +1689,7 @@ declare global {
"gcds-link": HTMLGcdsLinkElement;
"gcds-nav-group": HTMLGcdsNavGroupElement;
"gcds-nav-link": HTMLGcdsNavLinkElement;
"gcds-notice": HTMLGcdsNoticeElement;
"gcds-pagination": HTMLGcdsPaginationElement;
"gcds-phase-banner": HTMLGcdsPhaseBannerElement;
"gcds-radio-group": HTMLGcdsRadioGroupElement;
Expand Down Expand Up @@ -2580,6 +2601,20 @@ declare namespace LocalJSX {
*/
"onGcdsFocus"?: (event: GcdsNavLinkCustomEvent<void>) => void;
}
interface GcdsNotice {
/**
* Set the notice title.
*/
"noticeTitle": string;
/**
* Set notice title heading tag.
*/
"noticeTitleTag": 'h2' | 'h3' | 'h4' | 'h5';
/**
* Set notice type.
*/
"type": 'danger' | 'info' | 'success' | 'warning';
}
interface GcdsPagination {
/**
* List display - Current page number
Expand Down Expand Up @@ -3004,6 +3039,7 @@ declare namespace LocalJSX {
"gcds-link": GcdsLink;
"gcds-nav-group": GcdsNavGroup;
"gcds-nav-link": GcdsNavLink;
"gcds-notice": GcdsNotice;
"gcds-pagination": GcdsPagination;
"gcds-phase-banner": GcdsPhaseBanner;
"gcds-radio-group": GcdsRadioGroup;
Expand Down Expand Up @@ -3051,6 +3087,7 @@ declare module "@stencil/core" {
"gcds-link": LocalJSX.GcdsLink & JSXBase.HTMLAttributes<HTMLGcdsLinkElement>;
"gcds-nav-group": LocalJSX.GcdsNavGroup & JSXBase.HTMLAttributes<HTMLGcdsNavGroupElement>;
"gcds-nav-link": LocalJSX.GcdsNavLink & JSXBase.HTMLAttributes<HTMLGcdsNavLinkElement>;
"gcds-notice": LocalJSX.GcdsNotice & JSXBase.HTMLAttributes<HTMLGcdsNoticeElement>;
"gcds-pagination": LocalJSX.GcdsPagination & JSXBase.HTMLAttributes<HTMLGcdsPaginationElement>;
"gcds-phase-banner": LocalJSX.GcdsPhaseBanner & JSXBase.HTMLAttributes<HTMLGcdsPhaseBannerElement>;
"gcds-radio-group": LocalJSX.GcdsRadioGroup & JSXBase.HTMLAttributes<HTMLGcdsRadioGroupElement>;
Expand Down
2 changes: 2 additions & 0 deletions packages/web/src/components/gcds-heading/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
### Used by

- [gcds-error-summary](../gcds-error-summary)
- [gcds-notice](../gcds-notice)
- [gcds-stepper](../gcds-stepper)

### Graph
```mermaid
graph TD;
gcds-error-summary --> gcds-heading
gcds-notice --> gcds-heading
gcds-stepper --> gcds-heading
style gcds-heading fill:#f9f,stroke:#333,stroke-width:4px
```
Expand Down
2 changes: 2 additions & 0 deletions packages/web/src/components/gcds-icon/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- [gcds-file-uploader](../gcds-file-uploader)
- [gcds-link](../gcds-link)
- [gcds-nav-group](../gcds-nav-group)
- [gcds-notice](../gcds-notice)
- [gcds-pagination](../gcds-pagination)
- [gcds-search](../gcds-search)
- [gcds-topic-menu](../gcds-topic-menu)
Expand All @@ -41,6 +42,7 @@ graph TD;
gcds-file-uploader --> gcds-icon
gcds-link --> gcds-icon
gcds-nav-group --> gcds-icon
gcds-notice --> gcds-icon
gcds-pagination --> gcds-icon
gcds-search --> gcds-icon
gcds-topic-menu --> gcds-icon
Expand Down
110 changes: 110 additions & 0 deletions packages/web/src/components/gcds-notice/gcds-notice.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
@layer reset, default, type;

@layer reset {
:host {
display: block;

.gcds-notice {
text-align: left;
box-sizing: border-box;

slot {
display: initial;
}
}
}
}

@layer default {
:host .gcds-notice {
color: var(--gcds-notice-text);
display: grid;
grid-template-columns: var(--gcds-notice-icon-width) auto;
gap: var(--gcds-notice-icon-gap);

.notice__heading {
--gcds-heading-h2-desktop: var(
--gcds-notice-content-heading-font-desktop
);
--gcds-heading-h2-mobile: var(--gcds-notice-content-heading-font-mobile);
--gcds-heading-h4-desktop: var(
--gcds-notice-content-heading-font-desktop
);
--gcds-heading-h4-mobile: var(--gcds-notice-content-heading-font-mobile);
--gcds-heading-h5-desktop: var(
--gcds-notice-content-heading-font-desktop
);
--gcds-heading-h5-mobile: var(--gcds-notice-content-heading-font-mobile);
margin-block-start: var(--gcds-notice-content-heading-margin-block-start-desktop);

@media only screen and (width < 48em) {
margin-block-start: var(--gcds-notice-content-heading-margin-block-start-mobile);
}
}

.notice__icon {
margin: var(--gcds-notice-icon-margin);

&:before {
display: block;
width: var(--gcds-notice-border-width);
margin: 0 auto;
height: var(--gcds-notice-icon-before-height);
content: '';
background-color: currentColor;
}

&:after {
display: block;
width: var(--gcds-notice-border-width);
margin: 0 auto;
height: var(--gcds-notice-icon-after-height);
content: '';
background-color: currentColor;
}
}

::slotted(*) {
margin-block-start: 0;
font: var(--gcds-notice-content-slotted-font-desktop);

@media only screen and (width < 48em) {
font: var(--gcds-notice-content-slotted-font-mobile);
}
}

::slotted(*:last-child) {
margin-block-end: 0;
}

::slotted(*:not(:last-child)) {
margin-block-end: var(--gcds-notice-content-slotted-margin);
}

::slotted(ol),
::slotted(ul) {
margin-inline-start: var(--gcds-notice-content-slotted-list-margin);
padding: 0;
}
}
}

@layer type {
:host .gcds-notice {
&.notice--type-danger .notice__icon {
color: var(--gcds-notice-danger-text);
}

&.notice--type-info .notice__icon {
color: var(--gcds-notice-info-text);
}

&.notice--type-success .notice__icon {
color: var(--gcds-notice-success-text);
}

&.notice--type-warning .notice__icon {
color: var(--gcds-notice-warning-text);
}
}
}
Loading

0 comments on commit bb98233

Please sign in to comment.