Skip to content

Commit

Permalink
feat(system-message): add upgrade type (#450)
Browse files Browse the repository at this point in the history
* feat(system-message): add upgrade type

* fix: remove extra pin
  • Loading branch information
mezotv authored Aug 19, 2024
1 parent 93d5347 commit 39b5ad0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/core/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ <h3 class="title">System Messages</h3>
<discord-system-message type="pin"
><i>Favna</i> pinned <i>a message</i> to this channel. See all <i>pinned messages</i>.</discord-system-message
>
<discord-system-message type="upgrade"><i>Dominik</i> upgraded Skyra to premium for this server! 🎉</discord-system-message>
<discord-system-message type="alert">Warning! Warning! This library is the coolest of them all!</discord-system-message>
<discord-system-message type="error">Error! Cool overload!.</discord-system-message>
</discord-messages>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import DMCall from '../svgs/DMCall.js';
import DMEdit from '../svgs/DMEdit.js';
import DMMissedCall from '../svgs/DMMissedCall.js';
import Pin from '../svgs/Pin.js';
import ServerUpgrade from '../svgs/ServerUpgrade.js';
import SystemAlert from '../svgs/SystemAlert.js';
import SystemError from '../svgs/SystemError.js';
import Thread from '../svgs/Thread.js';
Expand Down Expand Up @@ -151,10 +152,10 @@ export class DiscordSystemMessage extends LitElement implements LightTheme {

/**
* The type of system message this is, this will change the icon shown.
* Valid values: `join`, `leave`, `call`, `missed-call`, `boost`, `edit`, `thread`, `pin`, `alert`, and `error`.
* Valid values: `join`, `leave`, `call`, `missed-call`, `boost`, `edit`, `thread`, `pin`, `alert`, `upgrade` and `error`.
*/
@property({ reflect: true, attribute: 'type' })
public accessor type: 'alert' | 'boost' | 'call' | 'edit' | 'error' | 'join' | 'leave' | 'missed-call' | 'pin' | 'thread' = 'join';
public accessor type: 'alert' | 'boost' | 'call' | 'edit' | 'error' | 'join' | 'leave' | 'missed-call' | 'pin' | 'thread' | 'upgrade' = 'join';

/**
* Whether this message is to show channel name changes, used to match Discord's style.
Expand All @@ -172,9 +173,9 @@ export class DiscordSystemMessage extends LitElement implements LightTheme {
public checkType() {
if (typeof this.type !== 'string') {
throw new TypeError('DiscordSystemMessage `type` prop must be a string.');
} else if (!['join', 'leave', 'call', 'missed-call', 'boost', 'edit', 'thread', 'pin', 'alert', 'error'].includes(this.type)) {
} else if (!['join', 'leave', 'call', 'missed-call', 'boost', 'edit', 'thread', 'pin', 'alert', 'error', 'upgrade'].includes(this.type)) {
throw new RangeError(
"DiscordSystemMessage `type` prop must be one of: 'join', 'leave', 'call', 'missed-call', 'boost', 'edit', 'thread', 'pin', 'alert', 'error'"
"DiscordSystemMessage `type` prop must be one of: 'join', 'leave', 'call', 'missed-call', 'boost', 'edit', 'thread', 'pin', 'alert', 'upgrade', 'error'"
);
}
}
Expand All @@ -200,7 +201,8 @@ export class DiscordSystemMessage extends LitElement implements LightTheme {
['thread', () => Thread()],
['pin', () => Pin()],
['alert', () => SystemAlert()],
['error', () => SystemError()]
['error', () => SystemError()],
['upgrade', () => ServerUpgrade()]
])}
</div>
<div class="discord-message-content">
Expand Down
15 changes: 15 additions & 0 deletions packages/core/src/components/svgs/ServerUpgrade.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { html, svg } from 'lit';
import { spread } from '../../spread.js';

const svgContent = svg`
<path
fill="#b9bbbe"
fill-rule="evenodd"
d="M1.575 9a2.25 2.25 0 0 0 0 3.18l.345.345c.128.128.323.15.488.075a2.25 2.25 0 0 1 3 3 .43.43 0 0 0 .06.48l.352.345a2.25 2.25 0 0 0 3.18 0l5.077-5.077a.75.75 0 0 1 1.02-1.02L16.425 9a2.25 2.25 0 0 0 0-3.18l-.345-.352a.42.42 0 0 0-.488-.06 2.25 2.25 0 0 1-3-3 .42.42 0 0 0-.068-.488l-.345-.345a2.25 2.25 0 0 0-3.18 0L7.671 2.903a.75.75 0 0 1-1.02 1.02zm7.508-4.725a.75.75 0 1 0-1.057 1.05l.517.525A.75.75 0 1 0 9.6 4.785l-.517-.525Zm2.063 2.063a.75.75 0 1 0-1.057 1.057l.517.525a.75.75 0 0 0 1.057-1.065l-.517-.525Zm2.063 2.063a.75.75 0 0 0-1.057 1.057l.517.525a.75.75 0 0 0 1.057-1.065l-.517-.525Z"
clip-rule="evenodd"
/>
`;

export default function ServerUpgrade(props: Record<string, unknown> = {}) {
return html`<svg ${spread(props)} aria-hidden="false" width="18" height="18" viewBox="0 0 18 18">${svgContent}</svg>`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ export class DiscordComponentsWrapper extends LitElement {
<discord-system-message type="pin"
><i>Favna</i> pinned <i>a message</i> to this channel. See all <i>pinned messages</i>.</discord-system-message
>
<discord-system-message type="upgrade"><i>Dominik</i> upgraded Skyra to premium for this server! 🎉</discord-system-message>
<discord-system-message type="alert">Warning! Warning! This library is the coolest of them all!</discord-system-message>
<discord-system-message type="error">Error! Cool overload!.</discord-system-message>
</discord-messages>
Expand Down

0 comments on commit 39b5ad0

Please sign in to comment.