Skip to content

Commit

Permalink
7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
icidasset committed Feb 26, 2021
1 parent 8e29182 commit 9c9f5b6
Show file tree
Hide file tree
Showing 12 changed files with 212 additions and 297 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

#### 7.0.0

Added back the `Types` module.


#### 6.1.0

- Forgot to update README
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ This package includes all the [Material icons](https://material.io/tools/icons/)

```elm
import Color
import Material.Icons as Filled exposing (offline_bolt)
import Material.Icons.Outlined as Outlined exposing (offline_bolt)
import Material.Icons as Filled
import Material.Icons.Outlined as Outlined
import Material.Icons.Types exposing (Coloring(..))

Filled.offline_bolt 16 (Filled.Color <| Color.rgb 96 181 204)
Outlined.offline_bolt 16 Outlined.Inherit
Filled.offline_bolt 16 (Color <| Color.rgb 96 181 204)
Outlined.offline_bolt 16 Inherit
```

### Preview
Expand Down
2 changes: 1 addition & 1 deletion docs.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
"name": "icidasset/elm-material-icons",
"summary": "Material Icons Library",
"license": "BSD-3-Clause",
"version": "6.1.0",
"version": "7.0.0",
"exposed-modules": [
"Material.Icons",
"Material.Icons.Outlined",
"Material.Icons.Round",
"Material.Icons.TwoTone"
"Material.Icons.TwoTone",
"Material.Icons.Types"
],
"elm-version": "0.19.0 <= v < 0.20.0",
"dependencies": {
Expand Down
52 changes: 7 additions & 45 deletions gen/generate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def icon_url(family_normal, icon)
FileUtils.mkdir_p OUT_DIR

# Download source of truth
# %x`curl -o #{escape(SOT_DIR)}/icons.json https://fonts.google.com/metadata/icons`
%x`curl -o #{escape(SOT_DIR)}/icons.json https://fonts.google.com/metadata/icons`



Expand Down Expand Up @@ -189,11 +189,9 @@ def generate(family)
end.join(", ")

append_to_file out_path, <<~HERE
module #{module_name} exposing (Coloring(..), Icon, #{exposed})
module #{module_name} exposing (#{exposed})
{-|
@docs Coloring, Icon
HERE

# Docs
Expand Down Expand Up @@ -224,48 +222,10 @@ module #{module_name} exposing (Coloring(..), Icon, #{exposed})
append_to_file out_path, <<~HERE
-}
import Color exposing (Color)
import Material.Icons.Internal exposing (..)
import Material.Icons.Types exposing (..)
import Svg exposing (Svg, g, line, polygon, polyline, rect, text, use, svg)
import Svg.Attributes as A exposing (baseProfile, clipRule, cx, cy, d, enableBackground, fill, fillOpacity, fillRule, id, overflow, points, r, x1, x2, xlinkHref, y1, y2)
{-| Should I use a [`Color`](https://package.elm-lang.org/packages/avh4/elm-color/latest/), or do I `Inherit` from the CSS color?
-}
type Coloring
= Color Color
| Inherit
{-| Type alias for our icons.
-}
type alias Icon msg =
Int -> Coloring -> Svg msg
{-| Internal helper for building icons.
-}
icon : List (Svg.Attribute msg) -> List (Svg msg) -> Icon msg
icon attributes nodes size coloring =
let
sizeAsString =
String.fromInt size
in
svg
((++)
attributes
[ A.height sizeAsString, A.width sizeAsString ]
)
[ g
[ case coloring of
Color color ->
fill (Color.toCssString color)
Inherit ->
fill "currentColor"
]
nodes
]
HERE

# Process each icon
Expand All @@ -274,8 +234,8 @@ module #{module_name} exposing (Coloring(..), Icon, #{exposed})

puts "Processing #{family}/#{icon_fn_name}"

# download_icon(family, icon)
# confirm_icon(family, icon)
download_icon(family, icon)
confirm_icon(family, icon)

svg = icon_svg(family, icon)
elm_icon_code = %x`./node_modules/.bin/html-elm "#{escape_quotes(svg)}"`
Expand Down Expand Up @@ -321,12 +281,14 @@ module #{module_name} exposing (Coloring(..), Icon, #{exposed})
# ====

%x`mv #{escape(ROOT)}/src/Material/Icons/Internal.elm #{escape(ROOT)}/src/Internal.elm`
%x`mv #{escape(ROOT)}/src/Material/Icons/Types.elm #{escape(ROOT)}/src/Types.elm`

%x`rm -rf #{escape(ROOT)}/src/Material`
%x`mv -f #{escape(OUT_DIR)}/* #{escape(ROOT)}/src`
%x`rm -rf #{escape(OUT_DIR)}`

%x`mv #{escape(ROOT)}/src/Internal.elm #{escape(ROOT)}/src/Material/Icons/Internal.elm`
%x`mv #{escape(ROOT)}/src/Types.elm #{escape(ROOT)}/src/Material/Icons/Types.elm`



Expand Down
79 changes: 29 additions & 50 deletions src/Material/Icons.elm

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions src/Material/Icons/Internal.elm
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
module Material.Icons.Internal exposing (..)

import Color
import Material.Icons.Types exposing (..)
import Svg exposing (Svg, g, svg)
import Svg.Attributes as A exposing (fill, height, width)


{-| Internal helper for building icons.
-}
icon : List (Svg.Attribute msg) -> List (Svg msg) -> Icon msg
icon attributes nodes size coloring =
let
sizeAsString =
String.fromInt size
in
svg
((++)
attributes
[ height sizeAsString, width sizeAsString ]
)
[ g
[ case coloring of
Color color ->
fill (Color.toCssString color)

Inherit ->
fill "currentColor"
]
nodes
]



-- Helper functions

Expand Down
79 changes: 29 additions & 50 deletions src/Material/Icons/Outlined.elm

Large diffs are not rendered by default.

63 changes: 18 additions & 45 deletions src/Material/Icons/Round.elm

Large diffs are not rendered by default.

79 changes: 29 additions & 50 deletions src/Material/Icons/Sharp.elm

Large diffs are not rendered by default.

82 changes: 32 additions & 50 deletions src/Material/Icons/TwoTone.elm

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions src/Material/Icons/Types.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module Material.Icons.Types exposing (Coloring(..), Icon)

{-|
@docs Coloring, Icon
-}

import Color exposing (Color)
import Svg exposing (Svg)



-- Types


{-| Should I use a [`Color`](https://package.elm-lang.org/packages/avh4/elm-color/latest/), or do I `Inherit` from the CSS color?
-}
type Coloring
= Color Color
| Inherit


{-| Type alias for our icons.
-}
type alias Icon msg =
Int -> Coloring -> Svg msg

0 comments on commit 9c9f5b6

Please sign in to comment.