├── LICENSE
├── README.md
└── _angled-edges.scss
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2017 Joseph Fusco
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Angled Edges :triangular_ruler: [](https://travis-ci.org/josephfusco/angled-edges) [](https://badge.fury.io/bo/angled-edges) [](https://badge.fury.io/js/angled-edges)
2 |
3 | A Sass mixin for creating angled edges on sections by dynamically encoding SVGs.
4 |
5 | Need angled edges in regular CSS? Check out the [Angled Edges Generator](https://angled-edges-generator.josephfus.co).
6 |
7 |
8 |
9 | ## Usage
10 |
11 | Import partial:
12 | ```scss
13 | @import "angled-edges";
14 | ```
15 |
16 | This mixin has 3 required parameters: **location**, **hypotenuse**, **fill**
17 | ```scss
18 | @include angled-edge($location, $hypotenuse, $fill);
19 | ```
20 |
21 | The main mixin creates an svg right triangle that is encoded, set as a background image of a pseudo element, and absolutely positioned.
22 |
23 | ### Examples
24 |
25 | https://codepen.io/fusco/pen/mzymKm
26 |
27 | ## Options
28 |
29 | | Parameter | Description |
30 | | ----------| ----------- |
31 | | `$location` | Location of shape relative to parent element
inside top
outside top
inside bottom
outside bottom
|
32 | | `$hypotenuse` | Side of the right triangle that the hypotenuse is on
upper left
upper right
lower left
lower right
|
33 | | `$fill` | Fill color of triangle |
34 | | `$height` | Optional - Height of triangle - Accepts a unitless integer that is equivalent to height in `px` |
35 | | `$width` | Optional - Width of triangle - Accepts a unitless integer that is equivalent to width in `px` (If nothing is passed triangle will span to a 100% fluid width) |
36 |
37 | ## Upgrading from 1.x
38 |
39 | Version 2 now defaults with a fluid width of 100%. Since this is the preferred value, width and height parameters have switched order with height now being first. This allows for easier usage where
40 | ```scss
41 | @include angled-edge('outside bottom', 'lower right', 150);
42 | ```
43 | now means a 150px tall with at a default of 100% width. If a fluid width is not needed, you can still pass in a unitless width like in 1.x. If you previously were using `background-size` to manipulate the shape, you will need to remove this property as the mixin also uses this to assist with making the shape full-width.
44 |
45 | ## Demo
46 |
47 | [https://angled-edges.josephfus.co](http://angled-edges.josephfus.co)
48 |
49 | ## Browser Support
50 |
51 | Anywhere SVG is supported.
52 |
53 | - [x] IE 9+
54 | - [x] Edge
55 | - [x] Firefox
56 | - [x] Chrome
57 | - [x] Safari
58 | - [x] Opera
59 | - [x] iOS Safari
60 | - [x] Opera Mini
61 | - [x] Android Browser
62 | - [x] Chrome for Android
63 |
64 | ## Project Ports
65 |
66 | + [Stylus Angled Edges](https://github.com/OlegWock/stylus-angled-edges)
67 |
--------------------------------------------------------------------------------
/_angled-edges.scss:
--------------------------------------------------------------------------------
1 | //-------------------------------------------------------------------------------------
2 | // Angled Edges v2.0.0 (https://github.com/josephfusco/angled-edges)
3 | // Copyright 2017 Joseph Fusco
4 | // Licensed under MIT (https://github.com/josephfusco/angled-edges/blob/master/LICENSE)
5 | //-------------------------------------------------------------------------------------
6 |
7 | /// Replace `$search` with `$replace` in `$string`.
8 | ///
9 | /// @author Hugo Giraudel
10 | /// @link http://www.sassmeister.com/gist/1b4f2da5527830088e4d
11 | ///
12 | /// @param {String} $string - Initial string
13 | /// @param {String} $search - Substring to replace
14 | /// @param {String} $replace ('') - New value
15 | /// @return {String} Updated string
16 | ///
17 | @function ae-str-replace($string, $search, $replace: '') {
18 | $index: str-index($string, $search);
19 |
20 | @if $index {
21 | @return str-slice($string, 1, $index - 1) + $replace + ae-str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
22 | }
23 |
24 | @return $string;
25 | }
26 |
27 | /// Encode SVG to use as background.
28 | ///
29 | /// @param {String} $string
30 | /// @return {String} Encoded svg data
31 | ///
32 | @function ae-svg-encode($string){
33 | $result: ae-str-replace($string, '