Skip to content

Commit

Permalink
Improve scss-addons
Browse files Browse the repository at this point in the history
  • Loading branch information
KODerFunk committed Apr 28, 2018
1 parent f09495b commit 9b25c51
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 48 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Feel free to start watching and ⭐ project in order not miss the release or upd
* 🏭 [Views](#-views)
* 🔦 [Debugging](#-debugging)
*[Helpers](#-helpers)
* 🎨 [SCSS addons](#-scss-addons)
* 🔌 [Integrations](#-integrations)
* [Turbolinks integration](#turbolinks-integration)
* [React.js integration](#reactjs-integration)
Expand Down Expand Up @@ -430,6 +431,12 @@ $someElement
.each$(($element, index) => { $element.removeClass(`.jquery-too_${index}`); });
```
## 🎨 SCSS addons
Normas package includes additional scss-files that will help in styling your application.
***To be continued...***
## 🔌 Integrations
### Turbolinks integration
Expand Down Expand Up @@ -501,11 +508,11 @@ Latest ✔ | Latest ✔ | Latest ✔ | 11+ ✔ | 9.1+ ✔ | Latest ✔
- More examples of usage with actual javascript plugins and libs
- Improve code style and quality
- Improve debugging
- Upgrade to Babel 7
- Optional jQuery usage
- Example on node.js with Express.js
- Use TypeScript
- Tests
- Upgrade to Babel 7
- Use TypeScript
- Example on node.js with Express.js
## 🤝 Contributing
Expand Down
2 changes: 2 additions & 0 deletions src/scss/_font-face.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// required typography

@function font-source-declaration($font-family, $file-path, $file-formats, $base64: false) {
$src: ();
$formats-map: (
Expand Down
52 changes: 52 additions & 0 deletions src/scss/_media.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@mixin media($query) {
$media-query: 'screen';
$tick: false;
$prop: false;
@each $q in $query {
$tick: is-not($tick);
@if $tick {
$prop: $q;
$media-query: $media-query + " and (#{$q}:";
} @else {
@if $prop == max-width {
$q: $q - 1px;
}
$media-query: $media-query + " #{$q})";
}
}
@media #{$media-query} {
@content;
}
}

$_media-variant: false;
$_media-args: false;
$_media-first-arg: false;
$_media-last-arg: false;

@mixin media-variants($media-variants, $media-prop: max-width) {
$_media-first-arg: true !global;
$index: 0;
$length: length($media-variants);
@each $args in $media-variants {
$_media-args: $args !global;
$_media-variant: map-get($_media-args, variant) !global;
$index: $index + 1;
@if $index == $length {
$_media-last-arg: true !global;
}
@if $_media-variant == base {
@content;
} @else {
@include media($media-prop $_media-variant) {
@content;
}
}
@if $_media-first-arg {
$_media-first-arg: false !global;
}
}
$_media-last-arg: false !global;
$_media-variant: false !global;
$_media-args: false !global;
}
23 changes: 10 additions & 13 deletions src/scss/_sugar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,22 @@
}

@mixin before($display: block, $content: '') {
&::before {
display: $display;
content: $content;
@content;
}
@include pseudo('&::before', $display, $content) { @content; }
}

@mixin after($display: block, $content: '') {
&::after {
display: $display;
content: $content;
@content;
}
@include pseudo('&::after', $display, $content) { @content; }
}

@mixin both($display: block, $content: '') {
&::before,
&::after {
display: $display;
@include pseudo('&::before, &::after', $display, $content) { @content; }
}

@mixin pseudo($selector, $display: block, $content: '') {
#{$selector} {
@if $display {
display: $display;
}
content: $content;
@content;
}
Expand Down
72 changes: 40 additions & 32 deletions src/scss/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,36 @@
font-size: $font-size;
}
@if $line-height {
line-height: $line-height;
@if type-of($line-height) == number or index(inherit initial) {
line-height: $line-height;
} @else {
@include font-prop($line-height);
}
}
@each $arg in $args {
$arg-part: nth($arg, 1);
@if type-of($arg-part) == color {
color: $arg;
} @else if index(capitalize lowercase uppercase, $arg-part) {
text-transform: $arg;
} @else if index(center left right, $arg-part) {
text-align: $arg;
} @else if index(blink line-through overline underline, $arg-part) {
text-decoration: $arg;
} @else if index(pre pre-line pre-wrap nowrap, $arg-part) {
white-space: $arg;
@include font-prop($arg);
}
}

@mixin font-prop($arg) {
$arg-part: nth($arg, 1);
@if type-of($arg-part) == color {
color: $arg;
} @else if index(capitalize lowercase uppercase, $arg-part) {
text-transform: $arg;
} @else if index(center left right, $arg-part) {
text-align: $arg;
} @else if index(blink line-through overline underline, $arg-part) {
text-decoration: $arg;
} @else if index(pre pre-line pre-wrap nowrap, $arg-part) {
white-space: $arg;
} @else {
$normalized-font-weight: font-weight($arg-part);
@if $normalized-font-weight {
$arg: set-nth($arg, 1, $normalized-font-weight);
font-weight: $arg;
} @else {
$normalized-font-weight: font-weight($arg-part);
@if $normalized-font-weight {
$arg: set-nth($arg, 1, $arg-part);
font-weight: $arg;
} @else {
@error 'Unknown argument in @mixin font(..., #{$arg-part}:#{type-of($arg-part)}, ..,)';
}
@error 'Unknown argument in @mixin font(..., #{$arg-part}:#{type-of($arg-part)}, ...)';
}
}
}
Expand All @@ -38,19 +46,6 @@
}
}

@mixin ellipsis($display: inline-block, $width: 100%) {
@if $display {
display: $display;
}
@if $width {
max-width: $width;
}
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
word-wrap: normal;
}

@function font-weight($font-weight) {
@if ($font-weight == 100 or $font-weight == thin or $font-weight == hairline) {
@return 100;
Expand All @@ -73,3 +68,16 @@
}
@return false;
}

@mixin ellipsis($display: inline-block, $width: 100%) {
@if $display {
display: $display;
}
@if $width {
max-width: $width;
}
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
word-wrap: normal;
}

0 comments on commit 9b25c51

Please sign in to comment.