-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mixins-logical-props): ✨ add
margin-right
mixin with its logic…
…al-props
- Loading branch information
1 parent
5b0c794
commit 464d498
Showing
2 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
@charset "UTF-8"; | ||
|
||
// @description | ||
// * mr mixin. | ||
// * This mixin generates CSS logical properties for margin-right. | ||
// * It will generate margin-right & margin-inline-start properties. | ||
|
||
// @access public | ||
|
||
// @version 1.0.0 | ||
|
||
// @author Khaled Mohamed | ||
|
||
// @license MIT | ||
|
||
// @repository: https://github.com/ZexLabs/sass-pire | ||
|
||
// @namespace logical-props | ||
|
||
// @module logical-props/mr | ||
|
||
// @dependencies: | ||
// * - meta.type-of (SASS function). | ||
// * - math.unit (SASS function). | ||
// * - list.index (SASS function). | ||
// * - Error.toggle (function). | ||
|
||
// @example | ||
// * .example { | ||
// * @include mr(2rem); | ||
// * } | ||
|
||
// @output | ||
// * .example { | ||
// * margin-inline-start: 2rem; | ||
// * margin-right: 2rem; | ||
// * } | ||
|
||
@use "sass:meta"; | ||
@use "sass:list"; | ||
@use "sass:math"; | ||
@use "../../development-utils/toggle-error-message" as Error; | ||
|
||
@mixin mr($value: 0) { | ||
@if meta.type-of($value) != number { | ||
content: Error.toggle("The parameter of mr mixin must be in a number type."); | ||
} @else { | ||
$get-unit: math.unit($value); | ||
|
||
@if $get-unit != "" { | ||
$all-units: ( | ||
cm, | ||
mm, | ||
in, | ||
px, | ||
pt, | ||
pc, | ||
"%", | ||
em, | ||
ex, | ||
ch, | ||
rem, | ||
vw, | ||
vh, | ||
vmin, | ||
vmax, | ||
dpi, | ||
dpcm, | ||
dppx, | ||
vw, | ||
svw, | ||
lvw, | ||
dvw, | ||
vh, | ||
lvh, | ||
dvh, | ||
vi, | ||
svi, | ||
lvi, | ||
vmin, | ||
svmin, | ||
lvmin, | ||
dvmin, | ||
vmax, | ||
svmax, | ||
lvmax, | ||
dvmax, | ||
vb, | ||
lvb, | ||
dvb | ||
) !default; | ||
|
||
@if list.index($all-units, $get-unit) { | ||
margin-inline-start: $value; | ||
margin-right: $value; | ||
} @else { | ||
content: Error.toggle("The parameter of mr mixin must be one of these values: (#{$all-units})."); | ||
} | ||
} @else { | ||
content: Error.toggle("The parameter of mr mixin must have a unit."); | ||
} | ||
} | ||
} |