Skip to content

I'm struggling with setting up the library #824

@angelikatyborska

Description

@angelikatyborska

I am trying to add bitstyles to a new project without changing any configuration. It is difficult.

I would like to just write:

@use '~bitstyles/scss/bitstyles';

and be able to use the library without any configuration but that's not possible.

Here are my problems:

1. The library tries to load custom font files

The first errors I see is this (truncated):


✘ [ERROR] Could not resolve "../assets/fonts/poppins-v20-latin-400.woff2"

    css/app.scss:749:11:
      749 │   src: url("../assets/fonts/poppins-v20-latin-400.woff2") format(...
          ╵            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] Could not resolve "../assets/fonts/poppins-v20-latin-400.woff"

    css/app.scss:749:79:
      749 │ ...f2"), url("../assets/fonts/poppins-v20-latin-400.woff") format...
          ╵              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

etc...

The instructions on https://bitcrowd.github.io/bitstyles/?path=/story/introduction-getting-started--page do not mention that I need to do to anything special to make fonts work. They mention:

You may need to provide your sass installation with the path for bitstyles’ sass. This should be:

But doing that does not resolve the font problems.

I don't want to have any fancy fonts at this stage of the project, I would be happy with a basic system-built in font. So I would like to overwrite the bitstyles config and not have to provide any custom font files.

2. Customization examples from docs doesn't work

When I want to start customizing the bitstyles config to change the font, I copy-paste this example from https://bitcrowd.github.io/bitstyles/?path=/story/introduction-getting-started--page :

@use '~bitstyles/scss/bitstyles/settings';
@use '~bitstyles/scss/bitstyles/design-tokens' with (
  $color-palette-text: #fff,
  $layout-size-base: 1.2rem
  /* lots of other options here */
);
@use '~bitstyles/scss/bitstyles/generic';
@use '~bitstyles/scss/bitstyles/base';
@use '~bitstyles/scss/bitstyles/atoms';
@use '~bitstyles/scss/bitstyles/organisms';
@use '~bitstyles/scss/bitstyles/utilities' with (
  $margin-breakpoints: (
    'l',
    'l3',
  )
);

This example gives me this error:

✘ [ERROR] Can't find stylesheet to import.
  ╷
2 │ ┌ @use '~bitstyles/scss/bitstyles/design-tokens' with (
3 │ │   $color-palette-text: #fff,
4 │ │   $layout-size-base: 1.2rem
5 │ │   /* lots of other options here */
6 │ │ );
  │ └─^
  ╵
  - 2:1  root stylesheet [plugin sass-plugin]

1 error
[watch] build finished, watching for changes...

I can figure out by looking at the source code that there are two main design-token files, "primary" and "secondary" so I change it to:

@use '~bitstyles/scss/bitstyles/settings';
@use '~bitstyles/scss/bitstyles/design-tokens/primary' with (
  $color-palette-text: #fff,
  $layout-size-base: 1.2rem
  /* lots of other options here */
);
@use '~bitstyles/scss/bitstyles/design-tokens/secondary';
@use '~bitstyles/scss/bitstyles/generic';
@use '~bitstyles/scss/bitstyles/base';
@use '~bitstyles/scss/bitstyles/atoms';
@use '~bitstyles/scss/bitstyles/organisms';
@use '~bitstyles/scss/bitstyles/utilities' with (
  $margin-breakpoints: (
    'l',
    'l3',
  )
);

Which then produces a new error:


✘ [ERROR] This variable was not declared with !default in the @used module.
  ╷
3 │   $color-palette-text: #fff,
  │   ^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  - 3:3  root stylesheet [plugin sass-plugin]

So I remove that variable from the file, which then produces this error:

✘ [ERROR] "Oops! Breakpoint ‘l3’ does not exist."
   ╷
63 │     @include media-query.get($breakpoint) {
   │     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ╵
  node_modules/bitstyles/scss/bitstyles/tools/_properties.scss 63:5       output-directional()
  node_modules/bitstyles/scss/bitstyles/utilities/margin/_index.scss 6:1  @forward
  node_modules/bitstyles/scss/bitstyles/utilities/_index.scss 24:1        @use
  - 8:1                                                                   root stylesheet [plugin sass-plugin]

Which leaves me with this code with no overriding any variables:

@use '~bitstyles/scss/bitstyles/settings';
@use '~bitstyles/scss/bitstyles/design-tokens/primary';
@use '~bitstyles/scss/bitstyles/design-tokens/secondary';
@use '~bitstyles/scss/bitstyles/generic';
@use '~bitstyles/scss/bitstyles/base';
@use '~bitstyles/scss/bitstyles/atoms';
@use '~bitstyles/scss/bitstyles/organisms';
@use '~bitstyles/scss/bitstyles/utilities';

3. How exactly do I customize bitstyles to stop importing a font file?

I had to read the source code to know that I can override $webfont-family-name to change thedefault font family and $webfont-variants to an empty array to stop any font files from getting imported. At first I tried to do:

@use '~bitstyles/scss/bitstyles/design-tokens/primary' with (
  $webfont-family-name: 'Arial',
  $webfont-variants: (),
);

Which doesn't work. I am forced to copy-paste the whole "primary" file into my bitstyles configuration in order to overwrite the fonts.

TL;DR: the simplest bitstyles configuration that compiles for me was this:

// bitstyles/scss/bitstyles.scss split into parts:
@use '~bitstyles/scss/bitstyles/settings';

// bitstyles/scss/bitstyles/design-tokens/primary.scss split into parts:
@use '~bitstyles/scss/bitstyles/design-tokens/animation';
@use '~bitstyles/scss/bitstyles/design-tokens/base-colors';
@use '~bitstyles/scss/bitstyles/design-tokens/base-palette';
@use '~bitstyles/scss/bitstyles/design-tokens/breakpoints';
@use '~bitstyles/scss/bitstyles/design-tokens/color-palette';
@use '~bitstyles/scss/bitstyles/design-tokens/layout';
@use '~bitstyles/scss/bitstyles/design-tokens/shadows';
@use '~bitstyles/scss/bitstyles/design-tokens/typography' with (
  $webfont-family-name: 'Arial',
  $webfont-variants: (),
);

@use '~bitstyles/scss/bitstyles/design-tokens/secondary';
@use '~bitstyles/scss/bitstyles/generic';
@use '~bitstyles/scss/bitstyles/base';
@use '~bitstyles/scss/bitstyles/atoms';
@use '~bitstyles/scss/bitstyles/organisms';
@use '~bitstyles/scss/bitstyles/utilities';

This process is not really obvious. It would be great to have public docs explaining how to approach creating config overrides.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions