Thanks to visit codestin.com
Credit goes to github.com

Skip to content

utopia.fyi scss doesn't output custom sizes. #16

@grignaak

Description

@grignaak

A scss blurb generated from utopia.fyi doesn't generate custom sizes into the css.

This utopia.fyi link gives the following blurb that does not generate the expected --space-s-l variable.

@use 'node_modules/utopia-core-scss/src/utopia' as utopia;
  
/* @link https://utopia.fyi/space/calculator?c=400,16,1.2,1240,20,1.25,5,2,1512-450&s=0.75|0.5|0.25,1.5|2|3|4|6,s-l&g=s,m,xl,12 */

:root {
  @include utopia.generateSpaceScale((
    "minWidth": 400,
    "maxWidth": 1240,
    "minSize": 16,
    "maxSize": 20,
    "positiveSteps": (1.5, 2, 3, 4, 6),
    "negativeSteps": (0.75, 0.5, 0.25),
    "customSizes": ("s-l"),
    "prefix": "space-",
    "relativeTo": "viewport-width",
  ));
}

Work arounds

Looking at the code for calculateCustomPairs, it is expecting customSizes to be a list, but utopia.fyi outputs a single value in a parenthesis which is interpreted by sass as a string.

The user can force the configuration into a list in a couple of ways:

  • Adding an additional custom size; and/or
  • Manually changing the config to use a list by adding trailing comma within customSizes
    • i.e. "customSizes": ("s-l",),

Proposal 1

One fix could be to have calculateCustomPairs convert the single value to a list.

$pairs: ();
$customSizes: map.get($config, "customSizes");
@if (meta.type-of($customSizes) == "string") {
  $customSizes: ($customSizes,);
}
@if (meta.type-of($customSizes) != "list") {
  @return $pairs;
}
...

Proposal 2

One fix could be to have utopia.fyi output generate the customSizes config list to have a trailing comma.

I think if this approach is taken then calculateCustomPairs should generate an error if customSizes is not a list instead of silently ignoring it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions