# CSS
# When should I create component classes?
We recommend a "utility-first" approach.
- Start with utility classes.
- If composing utility classes into a component class removes code duplication and encapsulates a clear responsibility, please do it.
This encourages an organic growth of component classes and prevents the creation of one-off unreusable classes. Also, the kind of classes that emerge from "utility-first" tend to be design-centered (e.g. .button, .alert, .card) rather than domain-centered (e.g. .merchant-report-widget, .productItem-header).
Examples of component classes that were created using "utility-first" include:
TODO: provide a real "utility-first" component. DO NOT provide fake examples.
Format:
- [component-filename](perma-link-to-source-code)
Inspiration:
- https://tailwindcss.com/docs/utility-first (opens new window)
- https://tailwindcss.com/docs/extracting-components (opens new window)
# Usage
# Overriding variables
Variables are imported as part of the base SCSS file.
To use a variable without including the full Infopiphany UI components’ styles, import the variable file and its functions directly:
@import '@infopiphany/ui/src/scss/functions';
@import '@infopiphany/ui/src/scss/variables';
.my-class {
color: $gray-200;
}
# Utilities
# Utility classes CSS bundle
To include all utility classes without including the full Infopiphany UI components’ styles, import the base utilities.scss file and its dependencies:
The
~character on the import depends on your build tools.
@import '~@infopiphany/ui/src/scss/functions';
@import '~@infopiphany/ui/src/scss/variables';
@import '~@infopiphany/ui/src/scss/utility-mixins/index'; // This imports all mixins
@import '~@infopiphany/ui/src/scss/utilities';
Specific mixin:
@import '@infopiphany/ui/src/scss/functions';
@import '@infopiphany/ui/src/scss/variables';
@import '@infopiphany/ui/src/scss/utility-mixins/border';
.border {
@include iphny-border-solid;
@include iphny-border-gray-200;
@include iphny-border-1;
@include iphny-border-rounded-base;
}
See utility-mixins/index.scss for a complete list of utility mixins available.
# Font utilities
# Font sizes
font-size-* increments by 2 and ends with font-size-80. Below are the available text classes utilities.
font-size-10font-size-12font-size-14font-size-16font-size-18font-size-20font-size-22
...font-size-80
# Font weight
Available classes for font weight.
ipy-font-weight-lighteripy-font-weight-lightipy-font-weight-normalipy-font-weight-semiboldipy-font-weight-boldipy-font-weight-bolder
# Line Height
Available classes for line height.
lh-100lh-110lh-120lh-130lh-140lh-150lh-160lh-170lh-180
# Letter Spacing
Available classes for letter spacing.
ls-1ls-15ls-2
# Cursor utilities
Available classes for cursors
ipy-cursor-pointeripy-cursor-grabipy-cursor-helpipy-cursor-not-allowedipy-cursor-wait
# Scroll utilities
Available classes for scroll
ipy-scroll-xipy-scroll-y