Skip to content

Commit

Permalink
feat(Global): Build unicode convenience function.
Browse files Browse the repository at this point in the history
Unicode escapes are hard to remember! And even harder for maintainers to decipher! This adds a function to abstract \00a0 into `unicode(nbsp)` or \00d7 into `unicode(multiplication-sign).

Fixes #29.
  • Loading branch information
kendrick committed Nov 3, 2016
1 parent 05ed683 commit 76faefd
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 10 deletions.
4 changes: 2 additions & 2 deletions rocketbelt/base/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ h4 {
font-weight: font-weight(light);

&::before {
content: '\a0\a0';
content: unicode(nbsp) + unicode(nbsp);
}
}
}
Expand Down Expand Up @@ -214,7 +214,7 @@ blockquote {
font-size: font-size(2);

&::before {
content: '\2015\a0';
content: unicode('horizontal-bar') + unicode(nbsp);
}
}

Expand Down
2 changes: 1 addition & 1 deletion rocketbelt/components/alerts/_alerts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ $message-families: (success, error, warning, info);
align-items: center;

&::after {
content: '\00d7';
content: unicode(multiplication-sign);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions rocketbelt/components/forms/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fieldset {

.validation-message::after {
color: color(gray, plus1);
content: '\00A0\2014\00A0';
content: unicode(nbsp) + unicode('horizontal-bar') + unicode(nbsp);
}
}
}
Expand Down Expand Up @@ -196,13 +196,13 @@ select {

&[required] {
& + label::after {
content: '\00a0(required)';
content: unicode(nbsp) + '(required)';
}
}

&:not([required]) {
& + label::after {
content: '\00a0(optional)';
content: unicode(nbsp) + '(optional)';
}
}
}
Expand Down Expand Up @@ -241,13 +241,13 @@ fieldset {

&[required] {
legend::after {
content: '\00a0(required)';
content: unicode(nbsp) + '(required)';
}
}

&:not([required]) {
legend::after {
content: '\00a0(optional)';
content: unicode(nbsp) + '(optional)';
}
}
}
2 changes: 1 addition & 1 deletion rocketbelt/components/modals/_modal-standard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@

.modal_header_close::before {
display: block;
content: '\00d7';
content: unicode(multiplication-sign);
font-size: ms(6);
line-height: 1;
}
Expand Down
3 changes: 2 additions & 1 deletion rocketbelt/tools/functions/_functions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
'opposite-direction',
'padding',
'str-replace',
'strip-unit';
'strip-unit',
'unicode';
22 changes: 22 additions & 0 deletions rocketbelt/tools/functions/_unicode.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@function unicode($character: '') {
$style: to_lower_case($character);
$characters: (
nbsp: '\00a0',
en-dash: '\2013',
em-dash: '\2014',
horizontal-bar: '\2015',
dagger: '\2020',
double-dagger: '\2021',
bullet: '\2022',
ellipsis: '\2026',
right-chevron: '\203a',
multiplication-sign: '\00d7'
);

@if map-has-key($characters, $character) {
@return map-get($characters, $character);
}
@else {
@error 'Character `#{$character}` does not exist in the map.';
}
}

0 comments on commit 76faefd

Please sign in to comment.