groton-school/colors 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

groton-school/colors

最新稳定版本:0.4.2

Composer 安装命令:

composer require groton-school/colors

包简介

Standard colors for Groton School apps

README 文档

README

Standard colors for Groton School apps

npm version Packagist Version

Install

Node npm

npm i @groton/colors

PHP composer

composer require groton-school/colors

Color Constants

The following colors are defined:

  • No Color -- a gray for information not associated with a color block
  • Red / RD
  • Orange / OR
  • Yellow / YL
  • Green / GR
  • Light Blue / LB
  • Dark Blue / DB
  • Purple / PR
  • Groton 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
Sass/SCSS kebab-case map.get(colors.$variants, 'no-color'), map.get(colors.$variants, 'red'), map.get(colors.$variants,'RD')
CSS kebab-case variable names var(--no-color), var(--red), var(--RD)
PHP CONSTANT_CASE Colors.NO_COLOR, 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.)

Color Components

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
SCSS/Sass map.get(colors.$variants, 'red-r'), map.get(colors.$variants, 'red-h')
CSS var(--red-r), var(--red-h)
PHP Colors.RED_R, COLORS.RED_H

Variants

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
The color on white (automatically adjusted for readability) Colors.RedOnWhite map.get(colors.$variants, 'red-on-white') var(--red-on-white) Colors.RED_ON_WHITE
The color on black (automatically adjusted for readability) Colors.RedOnBlack map.get(colors.$variants, 'red-on-black') var(--red-on-black) Colors.RED_ON_BLACK

Usage

TypeScript or JavasScript ESM modules

import * as Colors from '@groton/colors';

console.log(Colors.GrotonRed);
console.log(Colors.DarkBlueOnBlack);
console.log(Colors.TextOnPurple);

JavaScript CommonJS module

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;

Sass/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')};
}

CSS

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.4.0/vars.css"
/>

Use the variables:

.my-style {
  background: var(--groton-red);
}

.my-other-style {
  color: var(--dark-blue-on-black);
  background: var(--text-on-purple);
}
<iframe src="./preview.html" style="border: 0; height: 600px; width: 100%"></iframe>

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: TypeScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固