Skip to content

Commit e7c0f3a

Browse files
authored
feat: Adding $custom-prop-prefix to resolve naming conflicts
1 parent 37415e3 commit e7c0f3a

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

CHANGELOG-1.x.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.3.0 (2021-02-16)
2+
3+
- [](https://github.com/patternfly/patternfly-elements/commit/) feat: adding a $custom-prop-prefix variable to relieve naming conflict risk ($repo is too generic).
4+
15
## 1.2.0 ( 2021-02-12 )
26

37
### Features

elements/pfe-accordion/src/_shared-assets.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// NOTE: pfe-accordion uses shared styles that can be found in `pfe-sass/mixins/_components.scss`
21
@import "../../pfe-sass/pfe-sass";
32

43
$LOCAL: accordion;

elements/pfe-sass/functions/_custom-properties.scss

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
/// @param {Map} $map - Sass map of variables
1111
/// @param {String} $fallback [null] - Optional fallback override
1212
/// @param {Boolean} $use-fallback [true] - Optional hook to return a stack with no fallback value
13-
/// @requires $repo
13+
/// @requires $custom-prop-prefix
1414
/// @return {String} theme stack with fallback value from a sass map
15-
@function pfe-get-from-map($category, $key, $map, $fallback: null, $prefix: to-string($repo"-theme"), $use-fallback: true) {
15+
@function pfe-get-from-map($category, $key, $map, $fallback: null, $prefix: "#{$custom-prop-prefix}-theme", $use-fallback: true) {
1616
// Start building the variable declaration
1717
$var-declaration: "--#{$prefix}--";
1818
@if $prefix == "pf-c" {
@@ -43,7 +43,7 @@
4343
/// Returns CSS Var for the local component-scoped variable
4444
/// @param {String} $cssvar - Variable identifiers which are postfixed and combined using '--'
4545
/// @param {String} $region - Identifies the region or slot to which this is assigned
46-
/// @see $repo
46+
/// @see $custom-prop-prefix
4747
/// @see $LOCAL
4848
/// @example
4949
/// :host {
@@ -70,7 +70,7 @@
7070
}
7171

7272
// Start building the variable declaration
73-
$var-declaration: "--#{$repo}-#{$LOCAL}#{$region}--#{to-string($cssvar, '--')}";
73+
$var-declaration: "--#{$custom-prop-prefix}-#{$LOCAL}#{$region}--#{to-string($cssvar, '--')}";
7474

7575
@if $fallback != null {
7676
$var-declaration: "#{$var-declaration}, #{$fallback}";
@@ -83,7 +83,7 @@
8383
/// Fetches a CSS variable stack for broadcasted variables, providing a hook for context
8484
/// to influence the styles of children elements such as p tags or links.
8585
/// @param {String} $broadcast - name of the broadcast variable to apply
86-
/// @requires {String} $repo - Name of repo, which is "pfe"
86+
/// @requires {String} $custom-prop-prefix - Name of repo, which is "pfe"
8787
/// @example - scss
8888
/// :host {
8989
/// color: pfe-broadcasted(link);
@@ -98,10 +98,10 @@
9898
$fallback: ", #{map-get($pfe-broadcasted, #{to-string($broadcast,'--')})}";
9999
}
100100
@if not index($BROADCAST-VARS, first(str-split($broadcast, '--'))) {
101-
@error "--#{$repo}-broadcasted--#{$broadcast} variable is not currently supported.";
101+
@error "--#{$custom-prop-prefix}-broadcasted--#{$broadcast} variable is not currently supported.";
102102
}
103103
@else {
104-
@return var(--#{$repo}-broadcasted--#{to-string($broadcast,'--')}#{unquote($fallback)});
104+
@return var(--#{$custom-prop-prefix}-broadcasted--#{to-string($broadcast,'--')}#{unquote($fallback)});
105105
}
106106
}
107107

elements/pfe-sass/mixins/_custom-properties.scss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/// This will print all the broadcast variables, and set the value to the context of your choosing, like on-dark or on-saturated.
88
/// @param {String} $context - Look up values from contexts, i.e. "light" or "saturated"
99
/// @param {List | String} $broadcast [$BROADCAST-VARS] - Optionally specify only one broadcast variable instead of the whole set, i.e. "text"
10-
/// @see $repo
10+
/// @see $custom-prop-prefix
1111
/// @see $BROADCAST-VARS
1212
/// @example - scss - Usage in a container component, i.e. pfe-card
1313
/// :host {
@@ -58,12 +58,12 @@
5858

5959
@each $item in $list {
6060
@if not index($BROADCAST-VARS, $type) {
61-
@warn "--#{$repo}-broadcasted--#{$item} variable is not in the $BROADCAST-VARS list.";
61+
@warn "--#{$custom-prop-prefix}-broadcasted--#{$item} variable is not in the $BROADCAST-VARS list.";
6262
} @else if not pfe-broadcasted(#{$item}#{$context_string}) {
6363
@warn "#{$item}#{$context_string} value does not currently exist.";
6464
} @else {
6565
@if index($CONTEXTS, $context) != null {
66-
--#{$repo}-broadcasted--#{$item}: #{pfe-var(#{$item}#{$context_string})};
66+
--#{$custom-prop-prefix}-broadcasted--#{$item}: #{pfe-var(#{$item}#{$context_string})};
6767
} @else {
6868
@error "The #{$context} context does not appear to be part of a supported context.";
6969
}
@@ -76,7 +76,7 @@
7676
/// @param {String} $cssvar - Variable identifiers which are postfixed and combined using '--'
7777
/// @param {String} $value - The value of the css variable being defined
7878
/// @param {String} $region - Identifies the region or slot to which this is assigned
79-
/// @see $repo
79+
/// @see $custom-prop-prefix
8080
/// @see $LOCAL
8181
/// @example - scss
8282
/// :host {
@@ -94,11 +94,11 @@
9494
$styles: $v;
9595

9696
// Print the variable definition
97-
--#{$repo}-#{$LOCAL}#{$name}: #{$styles};
97+
--#{$custom-prop-prefix}-#{$LOCAL}#{$name}: #{$styles};
9898
}
9999
} @else {
100100
// Print the variable definition
101-
--#{$repo}-#{$LOCAL}#{$name}: #{$styles};
101+
--#{$custom-prop-prefix}-#{$LOCAL}#{$name}: #{$styles};
102102
}
103103
}
104104
}

elements/pfe-sass/variables/_1-definitions.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
/// Repository prefix
66
$repo: pfe !default;
77

8+
/// Variable used for prefixing custom properties
9+
$custom-prop-prefix: $repo;
10+
811
/// Default font size
912
$pfe-global--font-size-root: 16 !default;
1013

0 commit comments

Comments
 (0)