Skip to content

Commit

Permalink
FEATURE: Make key-bind() add the key to registry.
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteuSan committed Jan 18, 2022
1 parent d0918a8 commit 4c54ecd
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ A low-level SCSS library for building and managing token-driven design systems.
## Installation
```sh
# NPM
npm install @matteu-san/sentro --save
npm install @matteusan/sentro --save

# Yarn
yarn add @matteu-san/sentro --save
yarn add @matteusan/sentro --save
```

## Documentation
Expand All @@ -22,7 +22,7 @@ yarn add @matteu-san/sentro --save
#### SCSS Input
- Tokenize your UI while creating an intuitive theming API for your design system.
```scss
@use 'path/to/@matteu-san/sentro' with (
@use 'path/to/@matteusan/sentro' with (
$prefix: 'sdb',
$context: 'theme'
);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"dependencies": {
"@matteusan/himig-web": "0.1.5",
"@matteusan/sentro": "0.1.17",
"@matteusan/sentro": "0.1.18",
"sass-true": "6.0.1"
}
}
12 changes: 12 additions & 0 deletions src/core/_keys.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ $_ds-key-registry: ();
/// @return {string|*} returns an overrider css custom property with a new value.
@mixin bind($key, $value) {
--#{_sanitize-prefix($ds-prefix)}#{$key}: #{$value};
@if not check($key) {
@include _register-key($key, $value);
}
}

/// Sanitizes and verifies a prefix.
Expand All @@ -88,6 +91,15 @@ $_ds-key-registry: ();
@return '#{$prefix}-';
}

/// Registers a key to the key registry variable.
/// @access private
/// @param {string} $key
/// @param {*} $value
/// @return {void} key registry
@mixin _register-key($key, $value) {
$_ds-key-registry: map.set($_ds-key-registry, $key, $value) !global;
}

/// Validates a query if it's a registered key or not
/// @access private
/// @param {string} $query
Expand Down
2 changes: 1 addition & 1 deletion src/feature/_feature-validators.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
/// @param {string} $reference
/// @param {*} $query
/// @return {boolean|error} true if the query matches the referenced data type.
@function validate-data-type($reference, $query) {
@function is-type($reference, $query) {
@if meta.type-of($query) != unquote($reference) {
@error 'Invalid #{$reference}: #{$query}. Expecting a #{$reference}';
}
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@matteusan/sentro",
"version": "0.1.17",
"version": "0.1.18",
"description": "A low-level SCSS library for building and managing token-driven design systems.",
"main": "index.js",
"author": "Matteu",
Expand Down

0 comments on commit 4c54ecd

Please sign in to comment.