Skip to content

Commit

Permalink
Add alert component
Browse files Browse the repository at this point in the history
  • Loading branch information
nanoparsec committed Sep 20, 2023
1 parent cd82c37 commit fec7bc6
Show file tree
Hide file tree
Showing 12 changed files with 196 additions and 30 deletions.
1 change: 1 addition & 0 deletions aiur.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module.exports = {
molecules: {
file: "./lib/documentation/MOLECULES.md",
children: {
alert: "./lib/components/alert/alert.md",
announcement: "./lib/components/announcement/announcement.md",
cards: "./lib/components/cards/cards.md",
breadcrumb: "./lib/components/breadcrumb/breadcrumb.md",
Expand Down
4 changes: 4 additions & 0 deletions lib/assets/images/icons/close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lib/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Application specific code

// Components
@import "../../components/achtung-box/achtung-box";
@import "../../components/alert/alert";
@import "../../components/announcement/announcement";
@import "../../components/article-logo/article-logo";
@import "../../components/breadcrumb/breadcrumb";
Expand Down
42 changes: 42 additions & 0 deletions lib/components/alert/_alert.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.alert {
@extend %heading-font-regular;

display: flex;
flex-wrap: nowrap;
justify-content: space-between;

width: 100%;
padding: $spacer-xs;

font-size: $font-size-base;
color: $brand-text;

&--info {
background-color: $brand-primary-light;
}

&--warn {
background-color: $brand-tertiary-light;
}

&--error {
background-color: $brand-error;
}
}

.alert__text {
margin-bottom: 0;
}

.alert__btn {
@extend %base-button;

color: inherit;
background-color: transparent;
}

@include for-tablet-landscape-up {
.alert {
padding: $spacer-sm;
}
}
28 changes: 28 additions & 0 deletions lib/components/alert/alert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
title: Alert
description: Alert

```html
<div class="alert alert--info">
<p class="alert__text"><strong>Erfolg!</strong> Vielen Dank.</p>
<button class="alert__btn" type="button">
<span class="icon--close"></span>
<span class="sr-only">Schließen</span>
</button>
</div>

<div class="alert alert--warn">
<p class="alert__text"><strong>Das hat nicht geklappt!</strong> Bitte füllen Sie alle Felder aus.</p>
<button class="alert__btn" type="button">
<span class="icon--close"></span>
<span class="sr-only">Schließen</span>
</button>
</div>

<div class="alert alert--error">
<p class="alert__text"><strong>Das hat nicht geklappt!</strong> Bitte füllen Sie alle Felder aus.</p>
<button class="alert__btn" type="button">
<span class="icon--close"></span>
<span class="sr-only">Schließen</span>
</button>
</div>
```
24 changes: 24 additions & 0 deletions lib/components/buttons/_buttons.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
%base-button {
cursor: pointer;
user-select: none;

position: relative;

display: inline-block;

text-decoration: none;
white-space: nowrap;

background: none;
border: 0;

&:focus {
outline: none;
}

&:hover,
&:focus {
text-decoration: none;
}
}

.btn {
@extend %body-font-bold;

Expand Down
66 changes: 63 additions & 3 deletions lib/components/icons/_icons.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,65 @@
.icon {
&.icon-add {
@include icon-before("icons/add.svg", inherit, 1.5rem);
// Icon helper
@mixin icon-before($svg-path, $color, $height: 1rem) {
&::before {
content: " ";

display: block;

width: $height;
height: $height;

color: $color;

background-color: currentcolor;

mask-image: asset-url($svg-path);
mask-position: center;
mask-repeat: no-repeat;
mask-size: contain;
}
}

.icon--add {
@include icon-before("icons/add.svg", 1.5rem);
}

.icon--close {
@include icon-before("icons/close.svg", inherit, 1rem);
}

//Sizes
.icon--small {
width: $spacer-sm;
height: $spacer-sm;
}

.icon--medium {
width: $spacer-lg;
height: $spacer-lg;
}

.icon--big {
width: $spacer-xl;
height: $spacer-xl;
}

// Colors
.icon--brand-primary {
background: $brand-primary;
}

.icon--brand-secondary {
background: $brand-secondary;
}

.icon--brand-white {
background: $brand-white;
}

.icon--brand-black {
background: $brand-black;
}

.icon-close {
mask-image: asset-url("icons/close.svg");
}
4 changes: 3 additions & 1 deletion lib/components/icons/icons.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ Here are the icons that we have available for use in the system
_add_

```html
<span class="icon icon-add" role="presentation"></span>
<span class="icon icon--add" role="presentation"></span>

<span class="icon icon--close" role="presentation"></span>
```
29 changes: 6 additions & 23 deletions lib/fundamentals/_helpers.scss
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
// Icon helper
@mixin icon-before($svg-path, $color, $height: 1rem) {
&::before {
content: " ";

display: block;

width: $height;
height: $height;

color: $color;

background-color: currentcolor;

mask-image: asset-url($svg-path);
mask-position: center;
mask-repeat: no-repeat;
mask-size: contain;
}
}

// Only visible to screen reader
@mixin visually-hidden() {
/* https://snook.ca/archives/html_and_css/hiding-content-for-accessibility */
Expand All @@ -29,7 +8,11 @@

width: 1px;
height: 1px;
padding: 0;

white-space: nowrap;

clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
clip: rect(0, 0, 0, 0);
clip-path: inset(50%);
border: 0;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
title: Customer Proflie Edit Page
description: Customer Proflie Edit Page

## Alerts

See [All available alert styles](https://styleguide.socreatory.com/molecules/alert)

```html
<scroll-nav>
<nav class="navbar-wrapper">
Expand Down Expand Up @@ -49,7 +53,14 @@ description: Customer Proflie Edit Page
</header>

<main class="customer-profile-edit-page">
<section class="container">
<section class="container container--md">
<div class="alert alert--info">
<p class="alert__text"><strong>Erfolg!</strong> Vielen Dank.</p>
<button class="alert__btn" type="button">
<span class="icon--close"></span>
<span class="sr-only">Schließen</span>
</button>
</div>
<div class="login-form">
<h1 class="login-form__headline">Profil bearbeiten</h1>
<form class="form" id="#" novalidate="novalidate" action="/contact_forms" accept-charset="UTF-8" method="post">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
title: Customer Profile Page
description: Customer Profile Page

## Alerts

See [All available alert styles](https://styleguide.socreatory.com/molecules/alert)

```html
<scroll-nav>
<nav class="navbar-wrapper">
Expand Down Expand Up @@ -50,6 +54,13 @@ description: Customer Profile Page

<main class="customer-profile-page">
<section class="container container--md">
<div class="alert alert--info">
<p class="alert__text"><strong>Erfolg!</strong> Vielen Dank.</p>
<button class="alert__btn" type="button">
<span class="icon--close"></span>
<span class="sr-only">Schließen</span>
</button>
</div>
<dl>
<dt>Name</dt>
<dd>Mareike Müller</dd>
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "socreatory-styleguide",
"private": true,
"version": "2.1.0",
"version": "2.2.0",
"scripts": {
"aiur": "aiur -t ./dist",
"aiur:watch": "aiur -t ./dist --watch --liveserve 0.0.0.0:4001",
Expand Down Expand Up @@ -29,7 +29,6 @@
},
"dependencies": {
"@ungap/custom-elements-builtin": "^0.6.3",
"innoq-styleguide": "^14.0.0",
"lodash": "^4.17.20",
"tabelle": "^0.2.0",
"uitil": "^2.7.1"
Expand Down

0 comments on commit fec7bc6

Please sign in to comment.