Standard colors for Groton School apps
npm
npm i @groton/colors
composer
composer require groton-school/colors
Color constants are defined in camelCase, PascalCase, CONSTANT_CASE, or kebab-case as is normal for their language context. For color blocks, their standard abbreviation is also included in every language (e.g. RED
and RD
in PHP, or --red
and --rd
in CSS).
No Color
– a gray for information not associated with a color blockRed
Orange
Yellow
Green
LightBlue
DarkBlue
Purple
GrotonRed
– the school colorThe hex color is defined in every context. To specifically access the Hex, RGB, or HSL definition of a color, it is also provided with the matching suffix: --red-hex
or RedRgb
or RED_RGB
, etc.
Three color variants are provided with each color:
--text-on-red
, TEXT_ON_RED
, etc.$red-on-white
, RedOnWhite
, etc.RED_ON_BLACK
, $red-on-black
, etc.import * as Colors from '@groton/colors';
console.log(Colors.GrotonRed);
console.log(Colors.DarkBlueHsl);
console.log(Colors.PurpleRgb);
const Colors = require('@groton/colors');
console.log(Colors.GrotonRed);
console.log(Colors.DarkBlueHsl);
console.log(Colors.PurpleRgb);
use GrotonSchool\Colors;
echo Colors.GROTON_RED;
echo Colors.DARK_BLUE_HSL;
echo Colors.PURPLE_RGB;
// Sass $variables
@use '../node_modules/@groton/colors/colors';
// CSS --variables
@use '../node_modules/@groton/colors/vars.css';
.my-style {
background: colors.$groton-red;
}
.my-other-style {
color: colors.$dark-blue-hsl;
background: var(--purple-rgb);
}
// N.B. using the Sass variables to initialize CSS variables requires string interpolation
:root {
--my-color: #{colors.$green};
}
Add the CSS variables to a TypeScript module:
import '@groton/colors/vars.css';
Use a CDN to get the variables:
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@groton/colors@0.2.0/vars.css"
/>
Use the variables:
.my-style {
background: var(--groton-red);
}
.my-other-style {
color: var(--dark-blue-hsl);
background: var(--purple-rgb);
}