theme-squares

Примечание:

Эта страница - компонент, используемый на данной вики. Он предназначен для включения в другие страницы.

What this is

A component that displays a bunch of colored squares to show off a CSS theme's flair.

Designed by Woedenaz and componentised by Croquembouche.

This component is designed to be used for CSS themes, but it can be used on almost any page, if you really want.

Usage

On any wiki:

[[include component:theme-squares -=-
| color1-name=My Favourite Colour
| color1-variable=--fav-color
| color1-info=(191, 144, 0)
]]

Note the "-=-" after the component name. You do need to include that — otherwise all this text explaining how to use the component will appear on your page.

For this component, there are three parameters per color. Replace N with the number of the color.

colorN-nameThe name of the color. Pick whatever you want!
colorN-variableThe name of the CSS variable that contains this color.
The variable should hold three comma-separated numbers representing the RGB values of the color. This is consistent with BHL-style variables.
If your variables hold something else (e.g. a full RGB/RGBA or hex color), you will need to override the background color of each theme square manually with CSS.
colorN-infoSome info about the colour. Displaying the RGB values is typical. Keep it short.
If you don't want any text, add @@ @@ instead.
colorN-has-light-text
Optional. Default: 0
Either 0 or 1. Determines the font color on the square. Useful to make sure there is enough contrast between the background color and the text color.
If 1, the value of --swatch-text-light is used, or white (255, 255, 255) if it is not defined. Otherwise --swatch-text-dark, or black (0, 0, 0). Like all BHL-style CSS color variables, three numbers representing RGB values are expected.

A color can only be used if it's exposed as a CSS variable. All colors in a Black Highlighter theme have a corresponding CSS variable by default, so for BHL themes, this component should work out of the box. However, sigma9 does not use CSS variables, so the only CSS variables that are available will be any that you have defined in your theme.

This component can hold a maximum of 6 primary colors and 12 secondary colors. I recommend two primary colors and no more than six secondary colors.

To add a primary color, just add the top three of the above parameters to the include, as shown in the example.

To add a secondary color, it's the same, but replace 'color' with 'subcolor'.

Example

Here's a longer example, taken from the Black Highlighter theme:

[[include component:theme-squares -=-
| color1-name=Payne's Grey
| color1-variable=--gray-monochrome
| color1-info=(66, 66, 72)
| color1-has-light-text=1
| color2-name=Rosewood
| color2-variable=--bright-accent
| color2-info=(133, 0, 5)
| color2-has-light-text=1
| subcolor1-name=Alto
| subcolor1-variable=--very-light-gray-monochrome
| subcolor1-info=(215, 215, 215)
| subcolor2-name=White Smoke
| subcolor2-variable=--pale-gray-monochrome
| subcolor2-info=(244, 244, 244)
| subcolor3-name=Bastille
| subcolor3-variable=--dark-gray-monochrome
| subcolor3-info=(48, 48, 52)
| subcolor3-has-light-text=1
| subcolor4-name=Buccaneer
| subcolor4-variable=--medium-accent
| subcolor4-info=(100, 46, 44)
| subcolor4-has-light-text=1
| subcolor5-name=Maroon
| subcolor5-variable=--dark-accent
| subcolor5-info=(100, 3, 15)
| subcolor5-has-light-text=1
| subcolor6-name=Mango Tango
| subcolor6-variable=--newpage-color
| subcolor6-info=(221, 102, 17)
]]

This produces the following colored squares:

bhl-squares.png

Tweaking

You can adjust the appearance of the component with CSS.

The whole component has the .colors-container class, and any CSS that targets it should included that class to ensure that nothing else on the page is affected. Every colored square has class .color. The primary colors have a .colors parent and the secondary colors have a .subcolors parent.

You'll need to use !important to override a square's background.

For example, the Laughter and Knives theme adds a gradient background to the 9th secondary color like so:

.colors-container .subcolors .color:nth-of-type(9) {
    background: var(--pastel-rainbow) !important;
}

Tool to convert existing syntax to arguments for this component

{$color1-name}{$color1-variable}{$color1-info}
{$color2-name}{$color2-variable}{$color2-info}
{$color3-name}{$color3-variable}{$color3-info}
{$color4-name}{$color4-variable}{$color4-info}
{$color5-name}{$color5-variable}{$color5-info}
{$color6-name}{$color6-variable}{$color6-info}

{$subcolor1-name}{$subcolor1-variable}{$subcolor1-info}
{$subcolor2-name}{$subcolor2-variable}{$subcolor2-info}
{$subcolor3-name}{$subcolor3-variable}{$subcolor3-info}
{$subcolor4-name}{$subcolor4-variable}{$subcolor4-info}
{$subcolor5-name}{$subcolor5-variable}{$subcolor5-info}
{$subcolor6-name}{$subcolor6-variable}{$subcolor6-info}
{$subcolor7-name}{$subcolor7-variable}{$subcolor7-info}
{$subcolor8-name}{$subcolor8-variable}{$subcolor8-info}
{$subcolor9-name}{$subcolor9-variable}{$subcolor9-info}
{$subcolor10-name}{$subcolor10-variable}{$subcolor10-info}
{$subcolor11-name}{$subcolor11-variable}{$subcolor11-info}
{$subcolor12-name}{$subcolor12-variable}{$subcolor12-info}
Структурные: визуальный_элемент
версия страницы: 9, Последняя правка: 13 Авг. 2022, 14:29 (817 дней назад)
Пока не указано иное, содержимое этой страницы распространяется по лицензии Creative Commons Attribution-ShareAlike 3.0 License.