forticons 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +103 -0
- data/lib/build/data.json +1 -0
- data/lib/forticons/forticon.rb +107 -0
- data/lib/forticons/version.rb +3 -0
- data/lib/forticons.rb +8 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e159cff63ce281a56e5e58378055e2d77f04d979730a1a23ffc00d1f22286742
|
4
|
+
data.tar.gz: a763e20d4054018051e33f7745a2611822794510c3b19ca01e6d44842785a273
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3ec5c886da3644f7171d7d3cb7150049d553dce42ea5a7417ca72f12ddb6b4037978d3c8a966a172f449555bd88b559cb5a998141cf98320f8f7a03761fd88c5
|
7
|
+
data.tar.gz: 97a88864517cabe8bb5b9d3f06a9d33bf1a7a2050e766f02a1c9cd4775d5883df0950ededad9e7efcad5551b033d66391c3b6a636fd28382b26530ee397abf7d
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 GitHub Inc.
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# forticons
|
2
|
+
|
3
|
+
[![Gem version](https://img.shields.io/gem/v/forticons.svg)](https://rubygems.org/gems/forticons)
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
Add this to your `Gemfile`
|
8
|
+
|
9
|
+
```rb
|
10
|
+
gem 'forticons'
|
11
|
+
```
|
12
|
+
|
13
|
+
Then `bundle install`.
|
14
|
+
|
15
|
+
If using a framework like Rails, please follow the [installation instructions](https://primer.style/view-components/#installation) in the [Primer ViewComponents](https://primer.style/view-components) documentation.
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
```rb
|
20
|
+
require 'forticons'
|
21
|
+
icon = Forticons::Forticon.new("x")
|
22
|
+
icon.to_svg
|
23
|
+
# <svg class="forticon forticon-x" viewBox="0 0 16 16" width="16" height="16" version="1.1" "aria-hidden"="true"><path d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"></path></svg>
|
24
|
+
```
|
25
|
+
|
26
|
+
## Documentation
|
27
|
+
|
28
|
+
The `Forticon` class takes two arguments. The first is the symbol of the icon, and the second is a hash of arguments representing html attributes
|
29
|
+
|
30
|
+
### `symbol` _(required)_
|
31
|
+
|
32
|
+
This is the name of the forticon you want to use. For example `alert`. [Full list of icons](/)
|
33
|
+
|
34
|
+
### Options
|
35
|
+
|
36
|
+
* `:height` - When setting the height to a number, the icon will scale to that size. For example, passing `32`, will calculate the width based on the icon's natural size.
|
37
|
+
* `:width` - When setting the width to a number, the icon will scale to that size. For example, passing `32`, will calculate the width based on the icon's natural size.
|
38
|
+
|
39
|
+
If both `:width, :height` are passed into the options hash, then the icon will be sized exactly at those dimensions.
|
40
|
+
|
41
|
+
### Attributes
|
42
|
+
|
43
|
+
Once initialized, you can read a few properties from the icon.
|
44
|
+
|
45
|
+
#### `symbol`
|
46
|
+
|
47
|
+
Returns the string of the symbol name
|
48
|
+
|
49
|
+
```rb
|
50
|
+
icon = Forticons::Forticon.new("x")
|
51
|
+
icon.symbol
|
52
|
+
# "x"
|
53
|
+
```
|
54
|
+
|
55
|
+
#### `path`
|
56
|
+
|
57
|
+
Path returns the string representation of the path of the icon.
|
58
|
+
|
59
|
+
```rb
|
60
|
+
icon = Forticons::Forticon.new("x")
|
61
|
+
icon.path
|
62
|
+
# <path d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"></path>
|
63
|
+
```
|
64
|
+
|
65
|
+
#### `options`
|
66
|
+
|
67
|
+
This is a hash of all the `options` that will be added to the output tag.
|
68
|
+
|
69
|
+
```rb
|
70
|
+
icon = Forticons::Forticon.new("x")
|
71
|
+
icon.options
|
72
|
+
# {:class=>"forticon forticon-x", :viewBox=>"0 0 12 16", :version=>"1.1", :width=>12, :height=>16, :"aria-hidden"=>"true"}
|
73
|
+
```
|
74
|
+
|
75
|
+
#### `width`
|
76
|
+
|
77
|
+
Width is the icon's true width. Based on the svg view box width. _Note, this doesn't change if you scale it up with size options, it only is the natural width of the icon_
|
78
|
+
|
79
|
+
#### `height`
|
80
|
+
|
81
|
+
Height is the icon's true height. Based on the svg view box height. _Note, this doesn't change if you scale it up with size options, it only is the natural height of the icon_
|
82
|
+
|
83
|
+
#### `keywords`
|
84
|
+
|
85
|
+
Returns an array of keywords for the icon. The data comes from the [data file in lib](../data.json). Consider contributing more aliases for the icons.
|
86
|
+
|
87
|
+
```rb
|
88
|
+
icon = Forticons::Forticon.new("x")
|
89
|
+
icon.keywords
|
90
|
+
# ["remove", "close", "delete"]
|
91
|
+
```
|
92
|
+
|
93
|
+
### Methods
|
94
|
+
|
95
|
+
#### `to_svg`
|
96
|
+
|
97
|
+
Returns a string of the svg tag
|
98
|
+
|
99
|
+
```rb
|
100
|
+
icon = Forticons::Forticon.new("x")
|
101
|
+
icon.to_svg
|
102
|
+
# <svg class="forticon forticon-x" viewBox="0 0 16 16" width="16" height="16" version="1.1" "aria-hidden"="true"><path d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"></path></svg>
|
103
|
+
```
|