Standard colors for Groton School apps
npm install @groton/colorsStandard colors for Groton School apps


``sh`
npm i @groton/colors
`sh`
composer require groton-school/colors
The following colors are defined:
- No Color -- a gray for information not associated with a color blockRed
- / RDOrange
- / ORYellow
- / YLGreen
- / GRLight Blue
- / LBDark Blue
- / DBPurple
- / PRGroton Red
- -- the school color
Color constants are defined in the following cases for each language:
| Language | Case | Example |
| ---------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------- |
| TypeScript, JavaScript | PascalCase | Colors.NoColor, Colors.Red, Colors.RD |map.get(colors.$variants, 'no-color')
| Sass/SCSS | kebab-case | , map.get(colors.$variants, 'red'), map.get(colors.$variants,'RD') |var(--no-color)
| CSS | kebab-case variable names | , var(--red), var(--RD) |Colors.NO_COLOR
| PHP | CONSTANT_CASE | , Colors.RED, Colors.RD |
The hex color is defined in every context. The RGB and HSL components of the base color are also defined (RED_R, RED_G, RED_B in PHP, --red-h, --red-s, --red-l in CSS, etc.)
For the base color, the red, green, and blue components of RGB and the hue, saturation, and lightness components of HSL are defined for convenience in creating ranges of transparency/lightness/saturation.
| Language | Examples |
| ---------------------- | -------------------------------------------------------------------------- |
| TypeScript, Javascript | Colors.RedR, Colors.RedH |map.get(colors.$variants, 'red-r')
| SCSS/Sass | , map.get(colors.$variants, 'red-h') |var(--red-r)
| CSS | , var(--red-h) |Colors.RED_R
| PHP | , COLORS.RED_H |
Three color variants are provided for each base color, for use as colored text or text on colored backgrounds.
| Variant | TS/JS | SCSS | CSS | PHP |
| ------------------------------------------------------------------------- | ------------------- | ------------------------------------------- | --------------------- | --------------------- |
| Text on the color (automatically choosing white or black for readability) | Colors.TextOnRed | map.get(colors.$variants, 'text-on-red') | var(--text-on-red) | Colors.TEXT_ON_RED |Colors.RedOnWhite
| The color on white (automatically adjusted for readability) | | map.get(colors.$variants, 'red-on-white') | var(--red-on-white) | Colors.RED_ON_WHITE |Colors.RedOnBlack
| The color on black (automatically adjusted for readability) | | map.get(colors.$variants, 'red-on-black') | var(--red-on-black) | Colors.RED_ON_BLACK |
`ts
import * as Colors from '@groton/colors';
console.log(Colors.GrotonRed);
console.log(Colors.DarkBlueOnBlack);
console.log(Colors.TextOnPurple);
`
`js
const Colors = require('@groton/colors');
console.log(Colors.GrotonRed);
console.log(Colors.DarkBlueOnBlack);
console.log(Colors.TextOnPurple);
`
`php
use GrotonSchool\Colors;
echo Colors.GROTON_RED;
echo Colors.DARK_BLUE_ON_BLACK;
echo Colors.TEXT_ON_PURPLE;
`
`scss
// Sass $variables
@use '@groton/colors';
// CSS --variables
@use '@groton/colors/vars.css';
.my-style {
background: map.get(colors.$variants, 'groton-red');
}
.my-other-style {
color: map.get(colors.$variant, 'dark-blue-on-black');
background: var(--text-on-purple);
}
// N.B. using the Sass variables to initialize CSS variables requires string interpolation
:root {
--my-color: #{map.get(colors.$variants, 'green')};
}
`
Add the CSS variables to a TypeScript module:
`ts`
import '@groton/colors/vars.css';
Use a CDN to get the variables:
`html`
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@groton/colors@0.4.0/vars.css"
/>
Use the variables:
`css
.my-style {
background: var(--groton-red);
}
.my-other-style {
color: var(--dark-blue-on-black);
background: var(--text-on-purple);
}
``