Skip to content

Commit c0463c0

Browse files
authored
Add Discord's new branding, CSS & role colours (#1539)
1 parent bfb5f13 commit c0463c0

File tree

2 files changed

+108
-41
lines changed

2 files changed

+108
-41
lines changed

src/utils/colour.rs

Lines changed: 107 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -258,74 +258,63 @@ impl From<(u8, u8, u8)> for Colour {
258258
}
259259
}
260260

261-
macro_rules! colour {
262-
($(#[$attr:meta] $constname:ident, $val:expr;)*) => {
263-
impl Colour {
264-
$(
265-
#[$attr]
266-
pub const $constname: Colour = Colour($val);
267-
)*
268-
}
269-
}
270-
}
271-
272-
colour! {
261+
impl Colour {
273262
/// Creates a new [`Colour`], setting its RGB value to `(111, 198, 226)`.
274-
BLITZ_BLUE, 0x6FC6E2;
263+
pub const BLITZ_BLUE: Colour = Colour(0x6FC6E2);
275264
/// Creates a new [`Colour`], setting its RGB value to `(52, 152, 219)`.
276-
BLUE, 0x3498DB;
265+
pub const BLUE: Colour = Colour(0x3498DB);
277266
/// Creates a new [`Colour`], setting its RGB value to `(114, 137, 218)`.
278-
BLURPLE, 0x7289DA;
267+
pub const BLURPLE: Colour = Colour(0x7289DA);
279268
/// Creates a new [`Colour`], setting its RGB value to `(32, 102, 148)`.
280-
DARK_BLUE, 0x206694;
269+
pub const DARK_BLUE: Colour = Colour(0x206694);
281270
/// Creates a new [`Colour`], setting its RGB value to `(194, 124, 14)`.
282-
DARK_GOLD, 0xC27C0E;
271+
pub const DARK_GOLD: Colour = Colour(0xC27C0E);
283272
/// Creates a new [`Colour`], setting its RGB value to `(31, 139, 76)`.
284-
DARK_GREEN, 0x1F8B4C;
273+
pub const DARK_GREEN: Colour = Colour(0x1F8B4C);
285274
/// Creates a new [`Colour`], setting its RGB value to `(96, 125, 139)`.
286-
DARK_GREY, 0x607D8B;
275+
pub const DARK_GREY: Colour = Colour(0x607D8B);
287276
/// Creates a new [`Colour`], setting its RGB value to `(173, 20, 87)`.
288-
DARK_MAGENTA, 0xAD1457;
277+
pub const DARK_MAGENTA: Colour = Colour(0xAD1457);
289278
/// Creates a new [`Colour`], setting its RGB value to `(168, 67, 0)`.
290-
DARK_ORANGE, 0xA84300;
279+
pub const DARK_ORANGE: Colour = Colour(0xA84300);
291280
/// Creates a new [`Colour`], setting its RGB value to `(113, 54, 138)`.
292-
DARK_PURPLE, 0x71368A;
281+
pub const DARK_PURPLE: Colour = Colour(0x71368A);
293282
/// Creates a new [`Colour`], setting its RGB value to `(153, 45, 34)`.
294-
DARK_RED, 0x992D22;
283+
pub const DARK_RED: Colour = Colour(0x992D22);
295284
/// Creates a new [`Colour`], setting its RGB value to `(17, 128, 106)`.
296-
DARK_TEAL, 0x11806A;
285+
pub const DARK_TEAL: Colour = Colour(0x11806A);
297286
/// Creates a new [`Colour`], setting its RGB value to `(84, 110, 122)`.
298-
DARKER_GREY, 0x546E7A;
287+
pub const DARKER_GREY: Colour = Colour(0x546E7A);
299288
/// Creates a new [`Colour`], setting its RGB value to `(250, 177, 237)`.
300-
FABLED_PINK, 0xFAB1ED;
289+
pub const FABLED_PINK: Colour = Colour(0xFAB1ED);
301290
/// Creates a new [`Colour`], setting its RGB value to `(136, 130, 196)`.
302-
FADED_PURPLE, 0x8882C4;
291+
pub const FADED_PURPLE: Colour = Colour(0x8882C4);
303292
/// Creates a new [`Colour`], setting its RGB value to `(17, 202, 128)`.
304-
FOOYOO, 0x11CA80;
293+
pub const FOOYOO: Colour = Colour(0x11CA80);
305294
/// Creates a new [`Colour`], setting its RGB value to `(241, 196, 15)`.
306-
GOLD, 0xF1C40F;
295+
pub const GOLD: Colour = Colour(0xF1C40F);
307296
/// Creates a new [`Colour`], setting its RGB value to `(186, 218, 85)`.
308-
KERBAL, 0xBADA55;
297+
pub const KERBAL: Colour = Colour(0xBADA55);
309298
/// Creates a new [`Colour`], setting its RGB value to `(151, 156, 159)`.
310-
LIGHT_GREY, 0x979C9F;
299+
pub const LIGHT_GREY: Colour = Colour(0x979C9F);
311300
/// Creates a new [`Colour`], setting its RGB value to `(149, 165, 166)`.
312-
LIGHTER_GREY, 0x95A5A6;
301+
pub const LIGHTER_GREY: Colour = Colour(0x95A5A6);
313302
/// Creates a new [`Colour`], setting its RGB value to `(233, 30, 99)`.
314-
MAGENTA, 0xE91E63;
303+
pub const MAGENTA: Colour = Colour(0xE91E63);
315304
/// Creates a new [`Colour`], setting its RGB value to `(230, 131, 151)`.
316-
MEIBE_PINK, 0xE68397;
305+
pub const MEIBE_PINK: Colour = Colour(0xE68397);
317306
/// Creates a new [`Colour`], setting its RGB value to `(230, 126, 34)`.
318-
ORANGE, 0xE67E22;
307+
pub const ORANGE: Colour = Colour(0xE67E22);
319308
/// Creates a new [`Colour`], setting its RGB value to `(155, 89, 182)`.
320-
PURPLE, 0x9B59B6;
309+
pub const PURPLE: Colour = Colour(0x9B59B6);
321310
/// Creates a new [`Colour`], setting its RGB value to `(231, 76, 60)`.
322-
RED, 0xE74C3C;
311+
pub const RED: Colour = Colour(0xE74C3C);
323312
/// Creates a new [`Colour`], setting its RGB value to `(117, 150, 255)`.
324-
ROHRKATZE_BLUE, 0x7596FF;
313+
pub const ROHRKATZE_BLUE: Colour = Colour(0x7596FF);
325314
/// Creates a new [`Colour`], setting its RGB value to `(246, 219, 216)`.
326-
ROSEWATER, 0xF6DBD8;
315+
pub const ROSEWATER: Colour = Colour(0xF6DBD8);
327316
/// Creates a new [`Colour`], setting its RGB value to `(26, 188, 156)`.
328-
TEAL, 0x1ABC9C;
317+
pub const TEAL: Colour = Colour(0x1ABC9C);
329318
}
330319

331320
impl Default for Colour {
@@ -335,6 +324,84 @@ impl Default for Colour {
335324
}
336325
}
337326

327+
/// Colour constants used by Discord for their branding, role colour palette, etc.
328+
pub mod colours {
329+
pub mod branding {
330+
use crate::utils::Colour;
331+
332+
/// Creates a new [`Colour`], setting its value to `rgb(88, 101, 242)`.
333+
pub const BLURPLE: Colour = Colour(0x5865F2);
334+
/// Creates a new [`Colour`], setting its value to `rgb(87, 242, 135)`.
335+
pub const GREEN: Colour = Colour(0x57F287);
336+
/// Creates a new [`Colour`], setting its value to `rgb(254, 231, 92)`.
337+
pub const YELLOW: Colour = Colour(0xFEE75C);
338+
/// Creates a new [`Colour`], setting its value to `rgb(235, 69, 158)`.
339+
pub const FUCHSIA: Colour = Colour(0xEB459E);
340+
/// Creates a new [`Colour`], setting its value to `rgb(237, 66, 69)`.
341+
pub const RED: Colour = Colour(0xED4245);
342+
/// Creates a new [`Colour`], setting its value to `rgb(255, 255, 255)`.
343+
pub const WHITE: Colour = Colour(0xFFFFFF);
344+
/// Creates a new [`Colour`], setting its value to `rgb(35, 39, 42)`.
345+
pub const BLACK: Colour = Colour(0x23272A);
346+
}
347+
pub mod css {
348+
use crate::utils::Colour;
349+
350+
/// Creates a new [`Colour`], setting its value to `hsl(139, 47.3%, 43.9%)`.
351+
pub const POSITIVE: Colour = Colour(0x3BA55D);
352+
/// Creates a new [`Colour`], setting its value to `hsl(38, 95.7%, 54.1%)`.
353+
pub const WARNING: Colour = Colour(0xFAA81A);
354+
/// Creates a new [`Colour`], setting its value to `hsl(359, 82.6%, 59.4%)`.
355+
pub const DANGER: Colour = Colour(0xED4245);
356+
}
357+
pub mod roles {
358+
use crate::utils::Colour;
359+
360+
/// Creates a new [`Colour`], setting its value to `rgb(153, 170, 181)`.
361+
pub const DEFAULT: Colour = Colour(0x99AAB5);
362+
/// Creates a new [`Colour`], setting its value to `rgb(26, 188, 156)`.
363+
pub const TEAL: Colour = Colour(0x1ABC9C);
364+
/// Creates a new [`Colour`], setting its value to `rgb(17, 128, 106)`.
365+
pub const DARK_TEAL: Colour = Colour(0x11806A);
366+
/// Creates a new [`Colour`], setting its value to `rgb(46, 204, 113)`.
367+
pub const GREEN: Colour = Colour(0x2ECC71);
368+
/// Creates a new [`Colour`], setting its value to `rgb(31, 139, 76)`.
369+
pub const DARK_GREEN: Colour = Colour(0x1F8B4C);
370+
/// Creates a new [`Colour`], setting its value to `rgb(52, 152, 219)`.
371+
pub const BLUE: Colour = Colour(0x3498DB);
372+
/// Creates a new [`Colour`], setting its value to `rgb(32, 102, 148)`.
373+
pub const DARK_BLUE: Colour = Colour(0x206694);
374+
/// Creates a new [`Colour`], setting its value to `rgb(155, 89, 182)`.
375+
pub const PURPLE: Colour = Colour(0x9B59B6);
376+
/// Creates a new [`Colour`], setting its value to `rgb(113, 54, 138)`.
377+
pub const DARK_PURPLE: Colour = Colour(0x71368A);
378+
/// Creates a new [`Colour`], setting its value to `rgb(233, 30, 99)`.
379+
pub const MAGENTA: Colour = Colour(0xE91E63);
380+
/// Creates a new [`Colour`], setting its value to `rgb(173, 20, 87)`.
381+
pub const DARK_MAGENTA: Colour = Colour(0xAD1457);
382+
/// Creates a new [`Colour`], setting its value to `rgb(241, 196, 15)`.
383+
pub const GOLD: Colour = Colour(0xF1C40F);
384+
/// Creates a new [`Colour`], setting its value to `rgb(194, 124, 14)`.
385+
pub const DARK_GOLD: Colour = Colour(0xC27C0E);
386+
/// Creates a new [`Colour`], setting its value to `rgb(230, 126, 34)`.
387+
pub const ORANGE: Colour = Colour(0xE67E22);
388+
/// Creates a new [`Colour`], setting its value to `rgb(168, 67, 0)`.
389+
pub const DARK_ORANGE: Colour = Colour(0xA84300);
390+
/// Creates a new [`Colour`], setting its value to `rgb(231, 76, 60)`.
391+
pub const RED: Colour = Colour(0xE74C3C);
392+
/// Creates a new [`Colour`], setting its value to `rgb(153, 45, 34)`.
393+
pub const DARK_RED: Colour = Colour(0x992D22);
394+
/// Creates a new [`Colour`], setting its value to `rgb(149, 165, 166)`.
395+
pub const LIGHTER_GREY: Colour = Colour(0x95A5A6);
396+
/// Creates a new [`Colour`], setting its value to `rgb(151, 156, 159)`.
397+
pub const LIGHT_GREY: Colour = Colour(0x979C9F);
398+
/// Creates a new [`Colour`], setting its value to `rgb(96, 125, 139)`.
399+
pub const DARK_GREY: Colour = Colour(0x607D8B);
400+
/// Creates a new [`Colour`], setting its value to `rgb(84, 110, 122)`.
401+
pub const DARKER_GREY: Colour = Colour(0x546E7A);
402+
}
403+
}
404+
338405
#[cfg(test)]
339406
mod test {
340407
use std::u32;

src/utils/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mod message_builder;
1111
pub use argument_convert::*;
1212

1313
pub use self::{
14-
colour::Colour,
14+
colour::{colours, Colour},
1515
custom_message::CustomMessage,
1616
message_builder::{Content, ContentModifier, EmbedMessageBuilding, MessageBuilder},
1717
};

0 commit comments

Comments
 (0)