Skip to content

Commit

Permalink
release(notification): v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed May 28, 2024
1 parent eeee701 commit f62df49
Show file tree
Hide file tree
Showing 14 changed files with 131 additions and 10 deletions.
4 changes: 2 additions & 2 deletions index.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@
"dependencies": []
},
"notification": {
"version": "0.2.0",
"icon": true,
"version": "0.3.0",
"style": true,
"icon": false,
"test": true,
"install": false,
"react": false,
Expand Down
7 changes: 6 additions & 1 deletion src/console/icon/icon.json
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
["../../share/icon/caret-down.svg", "../../share/icon/caret-right.svg"]
[
"../../share/icon/caret-down.svg",
"../../share/icon/caret-right.svg",
"../../share/icon/warn.svg",
"../../share/icon/error.svg"
]
1 change: 1 addition & 0 deletions src/notification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Show notification.
### INotifyOptions

* duration(number): Notification duration.
* icon(string): Notification icon.

### IPosition

Expand Down
28 changes: 28 additions & 0 deletions src/notification/icon.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@font-face {
font-family: 'luna-notification-icon';
src: url('data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAZUAAsAAAAACdAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAG0AAACgIZAmVU9TLzIAAAF4AAAAPgAAAFZWzlGlY21hcAAAAbgAAADTAAACdAF1q7JnbHlmAAACjAAAAZ8AAAIw/FBRXGhlYWQAAAQsAAAAMQAAADZ25cSzaGhlYQAABGAAAAAdAAAAJAgCBA9obXR4AAAEgAAAABYAAABEFAH//GxvY2EAAASYAAAAFgAAACQHPAeQbWF4cAAABLAAAAAfAAAAIAEeAFBuYW1lAAAE0AAAASkAAAIWm5e+CnBvc3QAAAX8AAAAVwAAAHunB7sWeJxjYGRgYOBiMGCwY2BycfMJYeDLSSzJY5BiYGGAAJA8MpsxJzM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AElOBhAJAMAKPIKWwAAAHicY2BkYGBhAAEWhv9///9lYWZgZEAFggBbKAQbAAAAeJxjYGBgYEHB//8C8X8GEgAAwYQEDwAAeJxjYAACB4YwhhyGVYwS2CEAO7wC2QAAeJxjYGRgYBBkcGFgZgABJiDmAkIGhv9gPgMAEP4BbwB4nGWQPW7CQBSEx2BIAlKCFCkps1UKIpmfkgNAT0GXwpi1MbK91npBossJcoQcIaeIcoIcKGPzaGAtP38zb97uygAG+IWHenm4bWq9WrihOnGb9CDsk5+FO+jjRbhLfyjcwxumwn084p07eP4dnQFK4Rbu8SHcpv8p7JO/hDt4wrdwl/6PcA8r/An38eoN08gUsSncUif7LLRnef6utK1SU6hJMD5bC11oGzq9Ueujqg7J1LlYxdbkas6uzjKjSmt2OnLB1rlyNhrF4geRyZEigkGBuKkOS2gk2CNDCHvVvdQrpi0q+rVWmCDA+Cq1YKpokiGVxobJNY6sFQ48bUrXMa34Ws7kpLnMat4kIyv+77q3oxPRD7BtpkrMMOITX+SD5g75Pz0RXqgAAAB4nG3EOwqAMBBAwX2a+P/fw8IjSYgoQgLb5PqCtk4xksmnkX8zGTkGS0FJRU1DS0fPwMjEzCLmCke07vTuLt/XzaRdg/WqUbkIHEQcJ56bxI6KPP4cD3YA')
format('woff');
}

[class^='icon-'],
[class*=' icon-'] {
display: inline-block;
font-family: 'luna-notification-icon' !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

.icon-info:before {
content: '\f101';
}
.icon-check:before {
content: '\f102';
}
.icon-warn:before {
content: '\f103';
}
.icon-error:before {
content: '\f104';
}
5 changes: 5 additions & 0 deletions src/notification/icon/icon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
"../../share/icon/check.svg",
"../../share/icon/warn.svg",
"../../share/icon/error.svg"
]
4 changes: 4 additions & 0 deletions src/notification/icon/info.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 25 additions & 5 deletions src/notification/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export interface IPosition {
export interface INotifyOptions {
/** Notification duration. */
duration: number
/** Notification icon. */
icon?: string
}

/** IOptions */
Expand Down Expand Up @@ -72,7 +74,9 @@ export default class Notification extends Component<IOptions> {
duration: this.options.duration,
}
) {
const notification = new NotificationItem(this, content)
const notification = new NotificationItem(this, content, {
icon: options.icon || 'none',
})
this.notifications.push(notification)
this.add(notification)
setTimeout(() => this.remove(notification.id), options.duration)
Expand Down Expand Up @@ -129,7 +133,11 @@ class NotificationItem {
private $container: $.$
private notification: Notification
private content: string
constructor(notification: Notification, content: string) {
constructor(
notification: Notification,
content: string,
options: { icon: string }
) {
this.$container = $(this.container)
this.notification = notification
this.content = content
Expand All @@ -144,14 +152,26 @@ class NotificationItem {
),
})

this.initTpl()
this.initTpl(options.icon)
}
destroy() {
this.$container.remove()
}
private initTpl() {
private initTpl(icon: string) {
let iconName = icon
if (icon === 'success') {
iconName = 'check'
} else if (icon === 'warning') {
iconName = 'warn'
}
const iconHtml =
icon === 'none'
? ''
: `<div class="icon-container ${icon}"><span class="icon icon-${iconName}"></span></div>`
this.$container.html(
this.notification.c(`<div class="content">${this.content}</div>`)
this.notification.c(
`${iconHtml}<div class="content">${this.content}</div>`
)
)
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/notification/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"name": "notification",
"version": "0.2.0",
"description": "Show notifications"
"version": "0.3.0",
"description": "Show notifications",
"luna": {
"icon": true
}
}
2 changes: 2 additions & 0 deletions src/notification/story.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const def = story(
(container) => {
const x = select('X', ['left', 'center', 'right'], 'center')
const y = select('Y', ['top', 'bottom'], 'top')
const icon = select('Icon', ['none', 'info', 'success', 'warning', 'error'])

const inline = boolean('Inline Mode', false)

Expand Down Expand Up @@ -40,6 +41,7 @@ const def = story(

function notify() {
notification.notify(content, {
icon,
duration,
})
}
Expand Down
52 changes: 52 additions & 0 deletions src/notification/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,63 @@
margin-bottom: 16px;
}

.icon-container {
margin-right: 8px;
color: #fff;
border-radius: 50%;
width: 16px;
height: 16px;
text-align: center;
line-height: 16px;
&.info {
background: $color-info;
.icon {
position: relative;
top: -2px;
font-size: 12px;
}
}
&.success {
background: $color-success;
.icon {
position: relative;
top: -1px;
font-size: 12px;
}
}
&.warning {
color: $color-warning;
.icon {
font-size: 14px;
}
}
&.error {
color: $color-error;
.icon {
font-size: 14px;
}
}
}

.theme-dark {
.item {
border-color: $color-border-dark;
box-shadow: $box-shadow-dark;
color: $color-text-dark;
background: $color-bg-container-dark;
}
.icon-container {
&.info {
background: $color-info-dark;
}
&.success {
background: $color-success-dark;
}
&.warning {
color: $color-warning-dark;
}
&.error {
color: $color-error-dark;
}
}
}
File renamed without changes
File renamed without changes
File renamed without changes
1 change: 1 addition & 0 deletions src/text-viewer/icon/icon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["../../share/icon/check.svg"]

0 comments on commit f62df49

Please sign in to comment.