Skip to content

A way to easily use hierarchical accoutrement maps in Herman #345

@johncrim

Description

@johncrim

Given an accoutrement map like the following:

@use 'accoutrement' as a;

$colors: (
  'white': #f8f8f8,
  'warm-offwhite': hsl(28, 25, 93),
  'contrast-dark': #444,
  'contrast-light': #f8f8f8cc,
  'page': (
    'background': '#white'
  ),
  'header': (
    'background': '#white',
  ),
  'footer': (
    'background': hsl(240,67%,94%) ('shade': 80%),
  )
);
@include a.add-colors($colors); 

If I add these colors to the herman map, using:

@use 'herman';

/// @group colors
/// @colors site-colors
@include herman.herman-add('colors', 'site-colors', $colors);

The values in the root of the map are displayed correctly, but the submaps, and references, aren't. This problem isn't specific to displaying colors in herman - it would also be great to resolve and display hierarchical sizes, fonts, etc in herman.

If there were an accoutrement function that "flattened" the above map to:

$colors: (
  'white': #f8f8f8,
  'warm-offwhite': hsl(28, 25, 93),
  'contrast-dark': #444,
  'contrast-light': #f8f8f8cc,
  'page->background': #f8f8f8,
  'header->background': #f8f8f8,
  'footer->background': hsl(240,67%,94%) ('shade': 80%)
);

And then the color swatch rendering combined all keys with the same value under a single swatch (it may already do this), accoutrement + herman would be a nicer combination IMO.

The workaround is to manually map the hierarchical values to a new map that's added only to herman.

It would also be great to be able to flatten sub-maps for display in herman. Eg if I have:

$sizes: (
  'sm': (
    'icon-size': 24px,
    'page-margin': 1rem,
    'header-height': 3rem,
    'footer-height': '#sm->header-height',
    'vertical-spacing': 1.5rem,
    'horizontal-spacing': 2rem
  ),
  'lg': (
    'icon-size': 32px,
    'page-margin': 3rem,
    'header-height': 4rem,
    'footer-height': 5rem,
    'vertical-spacing': 2rem,
    'horizontal-spacing': 3rem
  ),
  'image': (
    'border-radius': 8px
  ),
  'text-column-width': 70ch,
  'page-min-width': 300px,
  'page-max-width': 1230px
);
@include a.add-sizes($sizes);

It would be nice to be able to display only the values within a specific submap (eg #sm) within herman.

Metadata

Metadata

Assignees

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