diff --git a/atst/ui_modules.py b/atst/ui_modules.py index 77671339..78f9e5ca 100644 --- a/atst/ui_modules.py +++ b/atst/ui_modules.py @@ -1,5 +1,14 @@ from tornado.web import UIModule +class Alert(UIModule): + def render(self, title, message=None, actions=None, level='info'): + return self.render_string( + "components/alert.html.to", + title=title, + message=message, + actions=actions, + level=level) + class Icon(UIModule): def render(self, name, classes=''): with open('static/icons/%s.svg' % name) as svg: diff --git a/scss/atat.scss b/scss/atat.scss index bc0fc120..5c42eb7e 100644 --- a/scss/atat.scss +++ b/scss/atat.scss @@ -18,6 +18,7 @@ @import 'components/global_navigation'; @import 'components/site_action'; @import 'components/empty_state'; +@import 'components/alerts'; @import 'sections/footer'; @import 'sections/login'; \ No newline at end of file diff --git a/scss/components/_alerts.scss b/scss/components/_alerts.scss new file mode 100644 index 00000000..a0030547 --- /dev/null +++ b/scss/components/_alerts.scss @@ -0,0 +1,75 @@ +/* + * Alerts + * @see https://designsystem.digital.gov/components/alerts/ + * @source https://github.com/uswds/uswds/blob/develop/src/stylesheets/components/_alerts.scss + */ + +@mixin alert { + padding: $gap * 2; + border-left-width: $gap / 2; + border-left-style: solid; + @include panel-margin; +} + +@mixin alert-level($level) { + $background-color: $color-aqua-lightest; + $border-color: $color-blue; + + @if $level == 'success' { + $background-color: $color-green-lightest; + $border-color: $color-green; + + } @else if $level == 'warning' { + $background-color: $color-gold-lightest; + $border-color: $color-gold; + + } @else if $level == 'error' { + $background-color: $color-red-lightest; + $border-color: $color-red; + } + + background-color: $background-color; + border-color: $border-color; + display: flex; + flex-direction: row; + align-items: flex-start; + + .alert__icon { + @include icon-color($border-color); + flex-grow: 0; + flex-shrink: 0; + margin-right: $gap * 2; + margin-left: 0; + } + + .alert__title { + @include h3; + } + + .alert__content { + .alert__message { + &:last-child { + > *:last-child { + margin-bottom: 0; + } + } + } + } +} + +.alert { + @include alert; + @include alert-level('info'); + + &.alert--success { + @include alert-level('success'); + } + + &.alert--warning { + @include alert-level('warning'); + } + + &.alert--error { + @include alert-level('error'); + } +} diff --git a/templates/components/alert.html.to b/templates/components/alert.html.to new file mode 100644 index 00000000..05cac613 --- /dev/null +++ b/templates/components/alert.html.to @@ -0,0 +1,35 @@ +{% set role = 'alertdialog' if actions else 'alert' %} +{% set levels = { + 'warning': { + 'icon': 'alert', + 'tone': 'assertive' + }, + 'error': { + 'icon': 'alert', + 'tone': 'assertive' + }, + 'info': { + 'icon': 'info', + 'tone': 'polite' + }, + 'success': { + 'icon': 'ok', + 'tone': 'polite' + } +} %} + +