forked from CenterForOpenScience/ember-osf-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove BsAlert component (CenterForOpenScience#1861)
## Purpose Remove usage of the BsAlert from ember osf web. ## Summary of Changes 1. Remove handbook docs 2. Stop subclassing BsAlert and just call it Alert 3. Fix View Only Link Banner 4. Fix Maintenance Banner 5. Fix Status Banners 6. Fix TOS Consent Banner 7. Fix tests
- Loading branch information
1 parent
5f1f7ad
commit f7fcaae
Showing
22 changed files
with
167 additions
and
126 deletions.
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
5 changes: 0 additions & 5 deletions
5
handbook-docs/components/bs-alert/demo-danger-hidden/component.ts
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
handbook-docs/components/bs-alert/demo-danger-hidden/template.hbs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
handbook-docs/components/bs-alert/demo-warn-no-dismiss/template.hbs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,66 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from 'tracked-built-ins'; | ||
import { action } from '@ember/object'; | ||
import { not } from '@ember/object/computed'; | ||
|
||
interface Args { | ||
type: string; | ||
onDismissed: () => void; | ||
onDismiss: () => boolean; | ||
dismissible: boolean; | ||
visible: boolean; | ||
} | ||
export default class Alert extends Component<Args> { | ||
// Note: Most of this was ripped from: | ||
// https://github.com/ember-bootstrap/ember-bootstrap/blob/v4.6.3/addon/components/bs-alert.js | ||
// and then simplified to remove fade transitions | ||
|
||
// Args | ||
onDismissed?: () => void; | ||
onDismiss?: () => boolean; | ||
type?: string; | ||
dismissible = true; | ||
@tracked visible = true; | ||
@not('visible') hidden!: boolean; | ||
|
||
constructor(owner: unknown, args: Args) { | ||
super(owner, args); | ||
this.type = args.type; | ||
if (args.visible === false) { | ||
this.visible = args.visible; | ||
} | ||
this.dismissible = args.dismissible; | ||
} | ||
|
||
get showAlert() { | ||
return this.visible; | ||
} | ||
|
||
@action | ||
dismiss() { | ||
if (this.args.onDismiss?.() !== false) { | ||
this.visible = false; | ||
} | ||
} | ||
|
||
show() { | ||
this.visible = true; | ||
} | ||
|
||
hide() { | ||
if (this.hidden) { | ||
return; | ||
} | ||
this.visible = false; | ||
this.args.onDismissed?.(); | ||
} | ||
|
||
@action | ||
showOrHide() { | ||
if (this.visible) { | ||
this.show(); | ||
} else { | ||
this.hide(); | ||
} | ||
} | ||
} |
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,52 @@ | ||
.alert { | ||
margin-bottom: 0; | ||
border-radius: 2px; | ||
padding: 10px 15px; | ||
|
||
p { | ||
margin-bottom: 0; | ||
} | ||
} | ||
|
||
.dismissable { | ||
padding-right: 35px; | ||
} | ||
|
||
.info { | ||
color: #31708f; | ||
background-color: #d9edf7; | ||
border-color: #bce8f1; | ||
} | ||
|
||
.warning { | ||
color: #8a6d3b; | ||
background-color: #fcf8e3; | ||
border-color: #faebcc; | ||
} | ||
|
||
.danger { | ||
color: #a94442; | ||
background-color: #f2dede; | ||
border-color: #ebccd1; | ||
} | ||
|
||
.success { | ||
color: #3c763d; | ||
background-color: #dff0d8; | ||
border-color: #d6e9c6; | ||
} | ||
|
||
.close { | ||
padding: 0; | ||
cursor: pointer; | ||
background: transparent; | ||
border: 0; | ||
appearance: none; | ||
float: right; | ||
font-size: 21px; | ||
font-weight: bold; | ||
line-height: 1; | ||
color: #000; | ||
text-shadow: 0 1px 0 #fff; | ||
opacity: 0.2; | ||
} |
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,19 @@ | ||
{{#if (and this.visible @visible)}} | ||
<div | ||
local-class='alert {{if @type @type}} {{if @dismissible 'dismissible'}}' | ||
class='{{@class}}' | ||
data-test-alert | ||
> | ||
{{#if this.dismissible}} | ||
<button | ||
type='button' | ||
local-class='close' | ||
aria-label={{t 'general.close'}} | ||
{{on 'click' this.dismiss}} | ||
> | ||
<span aria-hidden='true'><FaIcon @icon='times' /></span> | ||
</button> | ||
{{/if}} | ||
{{yield}} | ||
</div> | ||
{{/if}} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
29 changes: 11 additions & 18 deletions
29
lib/osf-components/addon/components/status-banner/styles.scss
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 |
---|---|---|
@@ -1,25 +1,18 @@ | ||
.StatusBanner { | ||
margin: 0; | ||
|
||
.StatusBanner__jumbo { | ||
padding: 0; | ||
margin: 0; | ||
} | ||
|
||
:global(.close) { | ||
top: 8px; | ||
right: 14px; | ||
} | ||
} | ||
.StatusBanner__jumbo { | ||
padding: 15px; | ||
color: inherit; | ||
background-color: $color-light; | ||
|
||
:global(.alert) { | ||
margin-bottom: 0; | ||
p { | ||
font-size: 21px; | ||
font-weight: 200; | ||
} | ||
|
||
:global(.jumbotron) { | ||
padding: 10px 40px; | ||
margin-bottom: 0; | ||
|
||
a { | ||
color: #2d6a9f; | ||
} | ||
a { | ||
color: $color-link-dark; | ||
} | ||
} |
11 changes: 5 additions & 6 deletions
11
lib/osf-components/addon/components/status-banner/template.hbs
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 |
---|---|---|
@@ -1,11 +1,10 @@ | ||
{{#each this.messages as |stat|}} | ||
<BsAlert | ||
<Alert | ||
@type={{stat.class}} | ||
@dismissible={{stat.dismiss}} | ||
class={{if stat.jumbo (local-class 'StatusBanner__jumbo')}} | ||
@visible={{true}} | ||
@class={{if stat.jumbo (local-class 'StatusBanner__jumbo')}} | ||
> | ||
<div class='{{if stat.jumbo 'jumbotron'}}'> | ||
<p data-test-status-message={{stat.id}}>{{t stat.id extra=stat.extra htmlSafe=true}}</p> | ||
</div> | ||
</BsAlert> | ||
<p data-test-status-message={{stat.id}}>{{t stat.id extra=stat.extra htmlSafe=true}}</p> | ||
</Alert> | ||
{{/each}} |
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
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 @@ | ||
export { default } from 'osf-components/components/alert/component'; |
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 @@ | ||
export { default } from 'osf-components/components/alert/template'; |
This file was deleted.
Oops, something went wrong.
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