npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@talenra/stylebox

v4.6.0

Published

SCSS-flavoured ready-to-use design basics and style presets for talenra UI

Downloads

162

Readme

talenra – Stylebox library for Sass

SCSS-flavoured ready-to-use design basics and style presets for talenra

Contents

Installation

Install the package.

npm i @talenra/stylebox

If you plan to use the typographic features of this library, you have to implement the required fonts in your app.

<!-- Place these lines in the header section of the index.html at the root of your app to load the required fonts. -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;1,300&display=swap" rel="stylesheet" />

Usage

Import the complete toolbox in your project.

// Import stylebox
@use '@talenra/stylebox';

Breakpoints

bp-get($name)

// Import stylebox
@use '@talenra/stylebox';

@media screen
and (max-width: #{stylebox.bp-get($name: "use-overlay-until") - 0.1px}) {
  // Styles for "overlay layout"
}

For media queries like above you might want to use the included and pre-configured media query manager (sass-mq). This is how the media query from the example above is written using sass-mq:

// Import stylebox
@use '@talenra/stylebox';

@include stylebox.mq($until: 'use-overlay-until') {
  // Styles for "overlay layout"
}
Parameters

|  Param | Default Value |  Description | | ------------ | ------------- | ------------------------------------------ | |  str $name |  null |  Breakpoint name, e.g. use-overlay-until |

The table below shows all supported breakpoint names.

|  Breakpoint Name |  Value |  Description | | ------------------------- | -------: | -------------------------------------------------------------------------------------------- | | use-overlay-until | 1200px | Use overlay-style layout for side-navigation and panels for viewports < use-overlay-until. | | use-panel-medium-from | 1588px | Use medium-sized panels for viewports >= use-panel-medium-from. | | use-panel-max-from | 1834px | Use max-sized panels for viewports >= use-panel-max-from. | | use-sidenav-medium-from | 1217px | Use medium-sized side-navigation for viewports >= use-sidenav-medium-from. | | use-sidenav-max-from | 1687.5px | Use max-sized side-navigation for viewports >= use-sidenav-max-from. |

Note that the suffix -until excludes the given boundary while -from includes it (e.g. overlay-style is used for viewports smaller 1200px while medium-sized panels are used for viewports of 1588px width).

Colors

color-get($name, $tint)

// Import stylebox
@use '@talenra/stylebox';

.title {
  // Use stylebox-color in your stylesheet
  color: stylebox.color-get('black', 80); // #333333
}
Parameters

|  Param | Default Value | Description | | ------------ | ------------: | -------------------------- | |  str $name | null | Color name, e.g. 'black' | |  int $tint | 100 | Tint, e.g. 80 |

The table below shows all supported color names and tints.

| Color Name |  Tint | Swatch | | ------------- | ----: | ------------------------------------------------------------ | | black | 100 |  #000000 | | | 80 |  #333333 | | | 70 |  #4D4D4D | | | 60 |  #666666 | | | 50 |  #808080 | | | 40 |  #999999 | | | 30 |  #B3B3B3 | | | 20 |  #CCCCCC | | | 10 |  #E6E6E6 | | | 5 |  #F2F2F2 | | | 2 |  #F8FBFF | | white | | #FFFFFF | | petrol-dark | 100 |  #005F71 | | | 5 |  #F4F6F7 | | petrol | 100 |  #0099A8 | | | 20 |  #D8EBEE | | | 10 |  #EAF4F6 | | denim-dark | 100 |  #04466A | | | 5 |  #F4F6F7 | | denim | 100 |  #0069A3 | | | 20 |  #CCE1ED | | | 10 |  #E5F0F6 | | status-green | 100 |  #00d000 | | status-red | 100 |  #E20057 | | status-orange | 100 |  #E26000 | | status-violet | 100 |  #B103C7 |

Return Value

Returns the HEX value of the given color/tint. The function will warn you about invalid color names and tints and return a fancy replacement color (deeppink).

Effects

Border radius

Presets for border-radiuses used for rounded corners.

| name | value | | ---- | ----- | | s* | 3px | | m | 6px |

*) Default value used if parameter $preset is omitted.

effect-get-border-radius()
// Import stylebox
@use '@talenra/stylebox';

.pane {
  // Use default border-radius default value in your stylesheet
  border-radius: stylebox.effect-get-border-radius();
}

.rounded {
  // Use with a non-default preset
  border-radius: stylebox.effect-get-border-radius('m');
}
Parameters

none

Return Value

Returns the border-radius default value. Get the value if you need it for further calculations. If you only need to apply the border-radius you should use effect-use-border-radius.

effect-use-border-radius()
// Import stylebox
@use '@talenra/stylebox';

.pane {
  // Apply border-radius in your stylesheet
  @include stylebox.effect-use-border-radius();
}

.rounded {
  // Use with a non-default preset
  @include stylebox.effect-use-border-radius('m');
}
Parameters

none

Return Value

Applies the default border-radius definition.

effect-use-drop-shadow()

// Import stylebox
@use '@talenra/stylebox';

.pane {
  // Apply drop-shadow in your stylesheet
  @include stylebox.effect-use-drop-shadow();
}
Parameters

none

Return Value

Applies the default box-shadow definition.

Typography

type-get-font()

// Import stylebox
@use '@talenra/stylebox';
@use '~other-lib' with (
  $font: stylebox.type-get-font()
);
Parameters

none

Return Value

Returns the default font-family.

type-use-font()

// Import stylebox
@use '@talenra/stylebox';

body {
  // Set default font and basic global typographic settings
  @include stylebox.type-use-font();
  // font-family: cfg.$font-family;
  // font-feature-settings: 'liga' 1, 'kern' 1;
  // -webkit-font-smoothing: antialiased;
}
Parameters

none

Return Value

Applies the default font-family and basic global typographic settings.

type-use($preset, $weight, $style, $flowtext, $suppress)

// Import stylebox
@use '@talenra/stylebox';

.shortcut {
  // Use typographic preset in your stylesheet
  @include stylebox.type-use('xxs');
  // font-size: 0.625rem;
  // line-height: 0.75rem;
  // font-weight: 300;
  // letter-spacing: 0.02em;
}
Parameters

All parameters are optional

|  Param |  Default Value | Description | | ---------------- | -------------- | -------------------------------------------------------------------------- | | enum $preset | m | Supported values: xxs, xs, s, m, l, h-s, h-m, h-l, h-xxl | | enum $weight | null | Supported values: light, regular, medium | | enum $style | null | Supported values: normal | | bool $flowtext | false | Optimize preset for flowtext (multi-line text) | | list $suppress | null | Suppress a given CSS property. Currently only supports line-height |

The table below shows all supported typographic presets.

|  preset | weight |  style | size | Notes | | ------- | ------------------------------ | ---------- | ------ | ---------------------------------------------------------------- | | xxs | light* | normal* | 10px | Used for shortcuts only (e.g. "alt-Y") | | xs | regular*, light | normal* | 12px | | s | regular*, light | normal* | 14px | | m* | medium, regular*, light | normal* | 16px | | l | medium, regular*, light | normal* | 18px | | h-s | regular* | normal* | 20px | | h-m | regular* | normal* | 24px | | h-l | regular* | normal* | 27px | Used for app header only. | | h-l | medium | normal* | 28px | Used for app header only. Weight medium uses bigger font-size. | | h-xxl | regular* | normal* | 40px | Used on login screen only. |

*) Default: Fallback value if param omitted (type-use() equals type-use($preset: 'm', $weight: 'regular', $style: 'normal', $flowtext: false))

Notes:

  • Preset h-xl is currently not available.
  • Presets with prefix h- are mainly used for headings.
Return Value

Applies declarations for font-size, line-height, font-weight, font-style and letter-spacing.

If you need to suppress a property, add it to the map passed in parameter $suppress.

.button {
  // Suppress `line-height`(e.g. for buttons and one-liners)
  @include stylebox.type-use('h-l', $suppress: ('line-height'));
  // font-size: 1.6875rem;
  // font-weight: 400;
  // font-style: normal;
  // letter-spacing: 0;
}

If you omit a parameter, the mixin will fallback to the default value. Same with invalid parameter values. The mixin will warn you about invalid parameter values.

Sassbox

@talenra/stylebox exposes the complete sassbox API.

@use '@talenra/stylebox';

.foo {
  margin-top: stylebox.px-to-rem(24);
}

Contributing

Contributions welcome. Please submit a pull request.

Versioning

We use SemVer for versioning.

License

This project is licensed under the ISC License - see the LICENSE file for details.

Contact

Lead talenra