-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore(deps): update tailwind to 3.2.7 * refactor(tailwind): insert type annotations * feat(atoms): add an alert component --------- Co-authored-by: Pascal Glass <[email protected]>
- Loading branch information
Showing
11 changed files
with
167 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
7 changes: 7 additions & 0 deletions
7
starter-kits/tailwind/source/default/patterns/01-atoms/alert/alert.stories.wingsuit.jsx
This file contains 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,7 @@ | ||
import './index'; | ||
|
||
const patternDefinition = require('./alert.wingsuit.yml'); | ||
|
||
export const wingsuit = { | ||
patternDefinition, | ||
}; |
61 changes: 61 additions & 0 deletions
61
starter-kits/tailwind/source/default/patterns/01-atoms/alert/alert.twig
This file contains 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,61 @@ | ||
{# | ||
Template | ||
#} | ||
|
||
{% set padding_classes = pattern_configuration('alert', '', 'paddings') %} | ||
|
||
{# -- Message list -- #} | ||
<div> | ||
{% for type, messages in message_list %} | ||
{% set classes = [ | ||
pattern_configuration('alert', '', 'bg_color')[type], | ||
pattern_configuration('alert', '', 'status_heading_styles')[type], | ||
pattern_configuration('alert', '', 'status_heading_color')[type], | ||
pattern_configuration('alert', '', 'message_color')[type], | ||
padding_classes | ||
] %} | ||
{% set is_message_with_title = status_headings[type] %} | ||
{% set is_message_with_icon = type in ['error', 'status', 'warning'] %} | ||
|
||
{% set attributes = attributes|default(create_attribute()) %} | ||
|
||
<div role="contentinfo" aria-labelledby="{{ title_ids[type] }}"{{ attributes.addClass(classes)|without('role', 'aria-label') }}> | ||
{% if type == 'error' %} | ||
<div role="alert"> | ||
{% endif %} | ||
{# -- Message header -- #} | ||
{% if is_message_with_title or is_message_with_icon %} | ||
<div class="relative"> | ||
{% if is_message_with_title %} | ||
<h2 id="{{ title_ids[type] }}"> | ||
{{ status_headings[type] }} | ||
</h2> | ||
{% if is_message_with_icon %} | ||
<div class="absolute -left-8 top-1/2 -translate-y-1/2"> | ||
{{ pattern('icon', {icon: type }, 'spritemap' ) }} | ||
</div> | ||
{% endif %} | ||
{% endif %} | ||
</div> | ||
{% endif %} | ||
{# -- Message content -- #} | ||
<div> | ||
{# -- Message list -- #} | ||
{% if messages|length > 1 %} | ||
<ul role="list"> | ||
{% for message in messages %} | ||
<li>{{ message }}</li> | ||
{% endfor %} | ||
</ul> | ||
{# -- Single message -- #} | ||
{% else %} | ||
{{ messages|first }} | ||
{% endif %} | ||
</div> | ||
{% if type == 'error' %} | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% endfor %} | ||
</div> | ||
|
48 changes: 48 additions & 0 deletions
48
starter-kits/tailwind/source/default/patterns/01-atoms/alert/alert.wingsuit.yml
This file contains 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,48 @@ | ||
alert: | ||
use: "@atoms/alert/alert.twig" | ||
label: Alert | ||
description: Alert component which plays nicely with the drupal message system. | ||
fields: | ||
title_ids: | ||
type: object | ||
label: Title Ids | ||
description: A list of unique ids keyed by message type. | ||
preview: | ||
status: 'status' | ||
error: 'error' | ||
success: 'success' | ||
info: 'info' | ||
status_headings: | ||
type: object | ||
label: Status Heading | ||
description: List of all status types. | ||
preview: | ||
status: 'Status' | ||
success: 'Success' | ||
info: 'Info' | ||
error: 'Error' | ||
message_list: | ||
type: object | ||
label: Messages | ||
description: List of messages to be displayed, grouped by type. | ||
preview: | ||
error: | ||
- 'Id exercitation elit commodo. Nisi et labore dolore do ullamco veniam labore veniam est nostrud velit aliquip sunt.' | ||
- 'Nisi et labore dolore do ullamco veniam labore veniam est nostrud velit aliquip sunt.' | ||
configuration: | ||
bg_color: | ||
status: 'bg-green-50' | ||
error: 'bg-red-50' | ||
success: 'bg-yellow-50' | ||
info: 'bg-blue-50' | ||
status_headings_color: | ||
status: 'text-green-700' | ||
error: 'text-red-700' | ||
success: 'text-yellow-700' | ||
info: 'text-blue-700' | ||
message_color: | ||
status: 'text-green-600' | ||
error: 'text-red-600' | ||
success: 'text-yellow-600' | ||
info: 'text-blue-600' | ||
paddings: 'pt-4 px-4 pb-6 pl-12' |
3 changes: 3 additions & 0 deletions
3
starter-kits/tailwind/source/default/patterns/01-atoms/alert/icons/error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
starter-kits/tailwind/source/default/patterns/01-atoms/alert/icons/info.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
starter-kits/tailwind/source/default/patterns/01-atoms/alert/icons/status.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
starter-kits/tailwind/source/default/patterns/01-atoms/alert/icons/warning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions
8
starter-kits/tailwind/source/default/patterns/01-atoms/alert/index.js
This file contains 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,8 @@ | ||
/** | ||
* alert | ||
*/ | ||
// Module dependencies | ||
import 'tokens'; | ||
|
||
// Module template | ||
import './alert.twig'; |
This file contains 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
This file contains 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