StyleSheetConstants
Package: Libraries.Web.Styles · Inherits from: Libraries.Language.Object
StyleSheetConstants holds fixed values that every layout and style uses when it writes its part of a stylesheet. It is a shared class, so there is only ever one copy, however many layouts and styles use it.
Example Code
use Libraries.Web.Styles.StyleSheetConstants
StyleSheetConstants constants
output "Pixels in one width of M: " + constants:PIXELS_PER_WIDTH_OF_M
Variables
number SPACING_8number SPACING_6number SMALL_LINE_HEIGHTnumber SPACING_2number SPACING_72number EXTRA_LARGE_3_FONT_SIZEinteger UNSET_POSITION: Where a list's markers sit: not chosen yet (the default, which writes nothing), outside the items' text, or inside it. List styles store one of these; authors choose with MarkersOutside or MarkersInside.number SPACING_44integer NUMBER_MARKERnumber PIXELS_PER_WIDTH_OF_M: The number of pixels in one width of M at the browser's normal text size. In a stylesheet this unit is written "rem", short for "root em". An "em" is a printer's measure, named after the width of a capital M. On the web, one rem is the text size of the whole page: 16 pixels, unless the reader has made text larger or smaller in their browser.number EXTRA_LARGE_4_FONT_SIZEinteger OUTSIDE_POSITIONnumber SPACING_11number EXTRA_SMALL_LINE_HEIGHTnumber SPACING_7number SPACING_2_5integer LIGHT_FONT_WEIGHT: Font weights, from light to bold.number SPACING_4number SMALL_FONT_SIZEnumber EXTRA_LARGE_7_FONT_SIZEnumber EXTRA_LARGE_9_FONT_SIZEnumber SPACING_3number SPACING_48number EXTRA_LARGE_2_LINE_HEIGHTinteger SEMIBOLD_FONT_WEIGHTinteger MEDIUM_FONT_WEIGHTnumber SPACING_32number BASE_LINE_HEIGHTnumber LARGE_FONT_SIZEnumber SPACING_96: Screen widths, in pixels, where a page's look may change: a look set "from" one of these applies on screens at least that wide. A small screen is a large phone turned sideways or a small tablet; a large screen, a laptop.number EXTRA_LARGE_7_LINE_HEIGHTnumber SPACING_28integer UNSET_MARKER: The marker a list puts before each item: none chosen yet (the default, which writes nothing), discs, numbers, or no marker at all. List styles store one of these; authors choose with actions such as UseDiscs, never with these numbers.number SPACING_0: Spacing, in pixels, for gaps, padding and margins, on a scale common on the web. Each step is 4 pixels: SPACING_2 is 8 pixels, SPACING_4 is 16. SPACING_0_5 is half a step (2 pixels), and SPACING_PIXEL is one pixel.number SPACING_56number EXTRA_LARGE_5_LINE_HEIGHTnumber SPACING_64integer CENTER_ALIGNnumber EXTRA_LARGE_9_LINE_HEIGHT: Font weights, from light to bold.number EXTRA_LARGE_6_LINE_HEIGHTnumber EXTRA_LARGE_SCREEN_WIDTH: Turns a size in pixels into text a stylesheet can use, measured in widths of the letter M (written "rem"; see PIXELS_PER_WIDTH_OF_M). Sizes written this way grow and shrink with the reader's text size, so 8 pixels becomes "0.5rem". Every layout and style uses this, so they all convert sizes the same way.number EXTRA_LARGE_FONT_SIZEnumber SPACING_40number SPACING_5integer DISC_MARKERnumber BASE_FONT_SIZEnumber SPACING_1integer LEFT_ALIGN: How a layout lines up its items across: stretched to the full width (the default), or at their own width on the left, in the center or on the right. Layouts store one of these; authors choose with actions such as AlignCenter, never with these numbers.number SPACING_52integer RIGHT_ALIGN: The marker a list puts before each item: none chosen yet (the default, which writes nothing), discs, numbers, or no marker at all. List styles store one of these; authors choose with actions such as UseDiscs, never with these numbers.number EXTRA_SMALL_FONT_SIZE: Text sizes, in pixels, from extra small to very large, on a scale common on the web. Each size has a font size and the line height that reads well with it.number LARGE_SCREEN_WIDTHinteger INSIDE_POSITION: Text sizes, in pixels, from extra small to very large, on a scale common on the web. Each size has a font size and the line height that reads well with it.number EXTRA_LARGE_3_LINE_HEIGHTnumber SPACING_14number EXTRA_LARGE_6_FONT_SIZEnumber EXTRA_LARGE_4_LINE_HEIGHTnumber SPACING_80number SPACING_0_5number EXTRA_LARGE_5_FONT_SIZEnumber SPACING_3_5number SPACING_12number EXTRA_LARGE_8_FONT_SIZEinteger NO_MARKER: Where a list's markers sit: not chosen yet (the default, which writes nothing), outside the items' text, or inside it. List styles store one of these; authors choose with MarkersOutside or MarkersInside.number EXTRA_LARGE_2_FONT_SIZEinteger BOLD_FONT_WEIGHT: Spacing, in pixels, for gaps, padding and margins, on a scale common on the web. Each step is 4 pixels: SPACING_2 is 8 pixels, SPACING_4 is 16. SPACING_0_5 is half a step (2 pixels), and SPACING_PIXEL is one pixel.number SPACING_16number SPACING_20number EXTRA_LARGE_8_LINE_HEIGHTnumber SPACING_10number SPACING_24integer NORMAL_FONT_WEIGHTnumber SPACING_PIXELnumber SPACING_1_5number SMALL_SCREEN_WIDTH: Screen widths, in pixels, where a page's look may change: a look set "from" one of these applies on screens at least that wide. A small screen is a large phone turned sideways or a small tablet; a large screen, a laptop.integer STRETCH_ALIGN: How a layout lines up its items across: stretched to the full width (the default), or at their own width on the left, in the center or on the right. Layouts store one of these; authors choose with actions such as AlignCenter, never with these numbers.number SPACING_9number SPACING_36number SPACING_60number EXTRA_LARGE_LINE_HEIGHTnumber LARGE_LINE_HEIGHTnumber MEDIUM_SCREEN_WIDTH
Actions
ToWidthOfM(number pixels)
Turns a size in pixels into text a stylesheet can use, measured in widths of the letter M (written "rem"; see PIXELS_PER_WIDTH_OF_M). Sizes written this way grow and shrink with the reader's text size, so 8 pixels becomes "0.5rem". Every layout and style uses this, so they all convert sizes the same way.
Parameters
pixelsnumber: A size in pixels, at the browser's normal text size.
Returns
text: The same size, as stylesheet text, such as "0.5rem".
Example
use Libraries.Web.Styles.StyleSheetConstants
StyleSheetConstants constants
output constants:ToWidthOfM(8)