Skip to content

Commit

Permalink
feat: use private mixins
Browse files Browse the repository at this point in the history
  • Loading branch information
frshwtr committed Dec 3, 2024
1 parent 24969b9 commit 14fda0a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions components/o-private-foundation/src/scss/o-colors/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,27 @@
/// Add a custom use case property.
///
/// @example Setting a 'stripe' usecase with background, text, and border colour within a component 'o-example'.
/// @include oColorsSetUseCase('o-example/stripe', (
/// @include oPrivateColorsSetUseCase('o-example/stripe', (
/// 'text': 'white',
/// 'background': 'black',
/// 'border': 'black-50'
/// ));
///
/// @example Setting a custom colour to a 'stripe' usecase with background.
/// @include oPrivateColorsSetColor('o-example/my-pink', #ff69b4);
/// @include oColorsSetUseCase('o-example/stripe', (
/// @include oPrivateColorsSetUseCase('o-example/stripe', (
/// 'background': 'o-example/my-pink',
/// ));
///
/// @example Deprecating all usecase properties (removing a colour usecase is a breaking change).
/// @include oColorsSetUseCase('o-example/stripe', (
/// @include oPrivateColorsSetUseCase('o-example/stripe', (
/// 'text': 'white',
/// 'background': 'black',
/// 'border': 'black-50'
/// ), (deprecated: 'o-example has no stripes anymore.'));
///
/// @example Deprecating particular usecase properties e.g. "border" (removing a usecase property is a breaking change).
/// @include oColorsSetUseCase('o-example/stripe', (
/// @include oPrivateColorsSetUseCase('o-example/stripe', (
/// 'text': 'white',
/// 'background': 'black',
/// 'border': 'black-50',
Expand All @@ -100,7 +100,7 @@
/// @param {String} $usecase - The name of the usecase, e.g. 'page'.
/// @param {Map} $colors - A map of properties ('text', 'background', 'border', or 'outline') to a color.
/// @param {Map} $opts [()] - A map of options. Accepts a `deprecated` key with a deprecation message for the usecase e.g. `$opts: (deprecated: 'your deprecation message')`, or a map to deprecate a specific property e.g. `(deprecated: (background: 'your deprecation message'))`.
@mixin oColorsSetUseCase($usecase, $colors, $opts: ()) {
@mixin oPrivateColorsSetUseCase($usecase, $colors, $opts: ()) {
$namespace: _oPrivateColorsGetNameSpace($usecase);
@if not $namespace {
@error 'The `$usecase` "#{inspect($usecase)}" has no namespace. ' +
Expand Down Expand Up @@ -152,7 +152,7 @@
$current-usecase-config: map-get($_o-pf-colors-usecases, $usecase);
@if ($namespace != 'o-colors' and $current-usecase-config and $current-usecase-config != $new-usecase-config) {
@error 'A usecase "#{$usecase}" has already been set. ' +
'Only default o-colors usecases may be overridden with `oColorsSetUseCase`. ' +
'Only default o-colors usecases may be overridden with `oPrivateColorsSetUseCase`. ' +
'If you would like to customise "#{$namespace}" colours, check its README for ' +
'customisation options, or contact the Origami team to propose new customisation features.';
}
Expand Down Expand Up @@ -184,7 +184,7 @@
// Set the page usecase first, which is needed for mixes.
@each $usecase, $colors, $opts in $_o-pf-colors-default-usecases {
@if $usecase == 'page' {
@include oColorsSetUseCase('o-colors/#{$usecase}', $colors, $opts);
@include oPrivateColorsSetUseCase('o-colors/#{$usecase}', $colors, $opts);
}
}
// Output colour mixies.
Expand All @@ -211,6 +211,6 @@
@mixin _oPrivateColorsSetDefaultUsecases {
@each $usecase, $colors, $opts in $_o-pf-colors-default-usecases {
$opts: if($opts, $opts, ());
@include oColorsSetUseCase('o-colors/#{$usecase}', $colors, $opts);
@include oPrivateColorsSetUseCase('o-colors/#{$usecase}', $colors, $opts);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $_o-pf-colors-is-initialised: false !default;
/// A map to define default palette colours:
/// A list of arguments for `oPrivateColorsSetColor`, except the project name.
///
/// @see _oColorsSetDefaultPaletteColors
/// @see _oPrivateColorsSetDefaultPaletteColors
/// @see oPrivateColorsSetColor
/// @type List
/// @access private
Expand All @@ -16,28 +16,28 @@ $_o-pf-colors-default-palette-colors: () !default;
/// This is also used to decide which colours are
/// allowed to have tones, when users request a
/// non-default tone.
/// @see _oColorsSetPaletteTones
/// @see _oPrivateColorsSetPaletteTones
/// @type Map
/// @access private
$_o-pf-colors-default-palette-tones: ();

/// A map to define default mixes in the palette.
/// @see _oColorsSetPaletteMixes
/// @see _oPrivateColorsSetPaletteTones
/// @type Map
/// @access private
$_o-pf-colors-default-palette-mixes: ();

/// A map to define default colour usecases:
/// A list of arguments for `oColorsSetUseCase`, except the project name.
/// A list of arguments for `oPrivateColorsSetUseCase`, except the project name.
///
/// @see _oColorsSetDefaultUsecases
/// @see oColorsSetUseCase
/// @see _oPrivateColorsSetDefaultPaletteColors
/// @see oPrivateColorsSetUseCase
/// @type List
/// @access private
$_o-pf-colors-default-usecases: () !default;

/// A map to store all set colour usecases.
/// @see oColorsSetUseCase
/// @see oPrivateColorsSetUseCase
/// @type Map
/// @access private
$_o-pf-colors-usecases: () !default;
Expand Down

0 comments on commit 14fda0a

Please sign in to comment.