Skip to content

Commit

Permalink
fix(alert): adjust close button positioning
Browse files Browse the repository at this point in the history
also pass icon size prop through button action element

fixes  #92
  • Loading branch information
Ashley Ryan authored and ashleyryan committed Jun 22, 2022
1 parent ba90734 commit 4318412
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 7 deletions.
153 changes: 153 additions & 0 deletions projects/core/custom-elements.json
Expand Up @@ -1225,6 +1225,14 @@
"attribute": "action",
"reflects": true
},
{
"kind": "field",
"name": "iconSize",
"type": {
"text": "string"
},
"attribute": "iconSize"
},
{
"kind": "field",
"name": "i18n"
Expand Down Expand Up @@ -1353,6 +1361,13 @@
},
"fieldName": "action"
},
{
"name": "iconSize",
"type": {
"text": "string"
},
"fieldName": "iconSize"
},
{
"name": "pressed",
"type": {
Expand Down Expand Up @@ -1550,6 +1565,18 @@
"module": "button-action/button-action.element.js"
}
},
{
"kind": "field",
"name": "iconSize",
"type": {
"text": "string"
},
"attribute": "iconSize",
"inheritedFrom": {
"name": "CdsButtonAction",
"module": "button-action/button-action.element.js"
}
},
{
"kind": "field",
"name": "i18n",
Expand Down Expand Up @@ -1682,6 +1709,17 @@
"module": "button-action/button-action.element.js"
}
},
{
"name": "iconSize",
"type": {
"text": "string"
},
"fieldName": "iconSize",
"inheritedFrom": {
"name": "CdsButtonAction",
"module": "button-action/button-action.element.js"
}
},
{
"name": "pressed",
"type": {
Expand Down Expand Up @@ -1852,6 +1890,18 @@
"module": "button-action/button-action.element.js"
}
},
{
"kind": "field",
"name": "iconSize",
"type": {
"text": "string"
},
"attribute": "iconSize",
"inheritedFrom": {
"name": "CdsButtonAction",
"module": "button-action/button-action.element.js"
}
},
{
"kind": "field",
"name": "i18n",
Expand Down Expand Up @@ -2002,6 +2052,17 @@
"module": "button-action/button-action.element.js"
}
},
{
"name": "iconSize",
"type": {
"text": "string"
},
"fieldName": "iconSize",
"inheritedFrom": {
"name": "CdsButtonAction",
"module": "button-action/button-action.element.js"
}
},
{
"name": "pressed",
"type": {
Expand Down Expand Up @@ -2665,6 +2726,18 @@
"module": "button-action/button-action.element.js"
}
},
{
"kind": "field",
"name": "iconSize",
"type": {
"text": "string"
},
"attribute": "iconSize",
"inheritedFrom": {
"name": "CdsButtonAction",
"module": "button-action/button-action.element.js"
}
},
{
"kind": "field",
"name": "i18n",
Expand Down Expand Up @@ -2817,6 +2890,17 @@
"module": "button-action/button-action.element.js"
}
},
{
"name": "iconSize",
"type": {
"text": "string"
},
"fieldName": "iconSize",
"inheritedFrom": {
"name": "CdsButtonAction",
"module": "button-action/button-action.element.js"
}
},
{
"name": "pressed",
"type": {
Expand Down Expand Up @@ -7836,6 +7920,18 @@
"module": "button-action/button-action.element.js"
}
},
{
"kind": "field",
"name": "iconSize",
"type": {
"text": "string"
},
"attribute": "iconSize",
"inheritedFrom": {
"name": "CdsButtonAction",
"module": "button-action/button-action.element.js"
}
},
{
"kind": "field",
"name": "i18n",
Expand Down Expand Up @@ -7980,6 +8076,17 @@
"module": "button-action/button-action.element.js"
}
},
{
"name": "iconSize",
"type": {
"text": "string"
},
"fieldName": "iconSize",
"inheritedFrom": {
"name": "CdsButtonAction",
"module": "button-action/button-action.element.js"
}
},
{
"name": "pressed",
"type": {
Expand Down Expand Up @@ -36078,6 +36185,18 @@
"module": "button-action/button-action.element.js"
}
},
{
"kind": "field",
"name": "iconSize",
"type": {
"text": "string"
},
"attribute": "iconSize",
"inheritedFrom": {
"name": "CdsButtonAction",
"module": "button-action/button-action.element.js"
}
},
{
"kind": "field",
"name": "i18n",
Expand Down Expand Up @@ -36223,6 +36342,17 @@
"module": "button-action/button-action.element.js"
}
},
{
"name": "iconSize",
"type": {
"text": "string"
},
"fieldName": "iconSize",
"inheritedFrom": {
"name": "CdsButtonAction",
"module": "button-action/button-action.element.js"
}
},
{
"name": "pressed",
"type": {
Expand Down Expand Up @@ -50244,6 +50374,18 @@
"module": "button-action/button-action.element.js"
}
},
{
"kind": "field",
"name": "iconSize",
"type": {
"text": "string"
},
"attribute": "iconSize",
"inheritedFrom": {
"name": "CdsButtonAction",
"module": "button-action/button-action.element.js"
}
},
{
"kind": "field",
"name": "i18n",
Expand Down Expand Up @@ -50376,6 +50518,17 @@
"module": "button-action/button-action.element.js"
}
},
{
"name": "iconSize",
"type": {
"text": "string"
},
"fieldName": "iconSize",
"inheritedFrom": {
"name": "CdsButtonAction",
"module": "button-action/button-action.element.js"
}
},
{
"name": "pressed",
"type": {
Expand Down
5 changes: 5 additions & 0 deletions projects/core/src/alert/alert-group.stories.ts
Expand Up @@ -43,6 +43,11 @@ export function API(args: any) {
export function alertGroup() {
return html`
<div cds-layout="vertical gap:sm">
<cds-alert-group status="info" aria-label="This is an example info alert group">
<cds-alert closable aria-label="This is an example info alert group">
This example is a closable alert inside an alert group with a status of "info".
</cds-alert>
</cds-alert-group>
<cds-alert-group status="info" aria-label="This is an example info alert group">
<cds-alert closable aria-label="This is an example info alert group">
This example is a closable alert inside an alert group with a status of "info".
Expand Down
5 changes: 5 additions & 0 deletions projects/core/src/alert/alert.element.scss
Expand Up @@ -36,6 +36,11 @@ $lightweight-alert-line-height: $cds-global-typography-body-line-height;
--color: var(--icon-color);
}

.alert-close-wrapper {
padding: var(--container-padding);
padding-bottom: 0;
}

cds-internal-close-button {
--color: inherit;
}
Expand Down
16 changes: 9 additions & 7 deletions projects/core/src/alert/alert.element.ts
Expand Up @@ -252,13 +252,15 @@ export class CdsAlert extends LitElement {
? html`<span class="alert-spacer" cds-layout="align:stretch">&nbsp;</span>`
: html``}
${this.type !== 'light' && this.closable
? html`<slot name="close-button">
<cds-internal-close-button
icon-size="${this.type === 'banner' ? '20' : '16'}"
@click="${() => this.closableController.close(true)}"
aria-label="${this.i18n.closeButtonAriaLabel}"
></cds-internal-close-button
></slot>`
? html`<span class="alert-close-wrapper"
><slot name="close-button">
<cds-internal-close-button
icon-size="${this.type === 'banner' ? '20' : '16'}"
@click="${() => this.closableController.close(true)}"
aria-label="${this.i18n.closeButtonAriaLabel}"
>
</cds-internal-close-button> </slot
></span>`
: html``}
</div>
`;
Expand Down
9 changes: 9 additions & 0 deletions projects/core/src/button-action/button-action.element.spec.ts
Expand Up @@ -47,4 +47,13 @@ describe('cds-button-action', () => {
await componentIsStable(component);
expect(component.hasAttribute('cds-button-action')).toBe(true);
});

it('should update the size of the icon via the iconSize property', async () => {
await componentIsStable(component);
expect(component.offsetHeight).toEqual(16);

component.iconSize = '20';
await componentIsStable(component);
expect(component.offsetHeight).toEqual(20);
});
});
3 changes: 3 additions & 0 deletions projects/core/src/button-action/button-action.element.ts
Expand Up @@ -41,6 +41,8 @@ export class CdsButtonAction extends CdsBaseButton {

@property({ type: String, reflect: true }) action: string;

@property({ type: String }) iconSize: string;

@i18n() i18n = I18nService.keys.actions;

@state({ type: Boolean, reflect: true, attribute: 'cds-button-action' }) protected cdsButtonAction = true;
Expand All @@ -53,6 +55,7 @@ export class CdsButtonAction extends CdsBaseButton {
<slot
><cds-icon
.shape=${this.shape ? this.shape : 'ellipsis-vertical'}
.size=${this.iconSize}
?solid=${this.pressed || this.expanded}
inner-offset=${1}
></cds-icon
Expand Down

0 comments on commit 4318412

Please sign in to comment.