svg-icons 0.1.0.1 → 0.1.0.2
raw patch · 14 files changed
+299/−85 lines, 14 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Icons.Cosmos: crescent :: Svg
- Icons.Cosmos: moon :: Svg
- Icons.Tools: cog6 :: Svg
- Icons.Tools: cog9 :: Svg
+ Core.Utils: cleanDecimals :: Int -> String -> String
+ Icons.Cosmos: moonCrescent :: Svg
+ Icons.Cosmos: moonFull :: Svg
Files
- src/Core/Geometry.hs +3/−3
- src/Core/Render.hs +10/−4
- src/Core/Style.hs +9/−3
- src/Core/Utils.hs +11/−6
- src/Icons/Business.hs +14/−8
- src/Icons/Computer.hs +38/−9
- src/Icons/Cosmos.hs +28/−17
- src/Icons/Human.hs +35/−9
- src/Icons/Math.hs +9/−1
- src/Icons/Office.hs +47/−15
- src/Icons/Religion.hs +24/−1
- src/Icons/Textarea.hs +47/−1
- src/Icons/Tools.hs +23/−7
- svg-icons.cabal +1/−1
src/Core/Geometry.hs view
@@ -2,7 +2,7 @@ -{- +{- | Module for geometrical shapes. -} @@ -61,7 +61,7 @@ -{- +{- | `starPolygonFirstSpecies` builds a first species regular star polygon. First species means that one vertice is skipped when joining vertices. @@ -106,7 +106,7 @@ `starOutline` builds a first species irregular star polygon. The difference with the previous function is the stroke: -The previous function's stroke runs inside the figure +the previous function's stroke runs inside the figure (so it would draw a pentagram), while this funtion's stroke runs outside the shape (so it would draw a star). There is no visual difference if you only fill the paths (with no stroke).
src/Core/Render.hs view
@@ -28,12 +28,14 @@ This function also adds the correct DOCTYPE and xml:ns Example use: + >renderSvgFiles > "./assets/img/" > [ (,) "sun" (sun 14) > , (,) "moon" moon > , (,) "crescent" crescent > ] + This will create 3 files inside the ./assets/svg/ folder, namely sun.svg, moon.svg and crescent.svg -} @@ -59,6 +61,7 @@ an export line. Example use: + >myCancelIcon :: Svg >myCancelIcon = > svg @@ -70,8 +73,10 @@ > "./assets/svg/" > [ (,) "cancel" myCancelIcon > ] + This call will create a cancel.jsx file inside the ./assets/svg/ folder with the following code inside: + >import React from 'react'; > >export const cancel = @@ -80,6 +85,7 @@ > <path d="M 0.1,-0.1 L 0.1,-0.8 A 0.1,0.1 0.0 1,0 -0.1,-0.8 L -0.1,-0.1 L -0.8,-0.1 A 0.1,0.1 0.0 1,0 -0.8,0.1 L -0.1,0.1 L -0.1,0.8 A 0.1,0.1 0.0 1,0 0.1,0.8 L 0.1,0.1 L 0.8,0.1 A 0.1,0.1 0.0 1,0 0.8,-0.1 Z" transform="rotate(45,0,0)" /> > </g> ></svg> + -} renderSvgReact :: FilePath -> [ (FilePath , Svg) ] -> IO () renderSvgReact folder svgs = @@ -98,13 +104,13 @@ `svgToReact` is internally used in the previous function so you don't have to call it manually. -This function writes the "import React from 'react';" line +This function writes the @import React from 'react';@ line and the export line; and more importantly, changes all hyphen-joined attributes to camelCase, because React will complain otherwise. -For example, "stroke-width" changes to "strokeWidth" and "text-anchor" -changes to "textAnchor". +For example, @stroke-width@ changes to @strokeWidth@ and @text-anchor@ +changes to @textAnchor@. -IMPORTANT: This function does not currently aim to be exhaustive, +__IMPORTANT:__ This function does not currently aim to be exhaustive, which means that you may encounter some hyphen-joined attribute which is not converted to camelCase and raises a React error. You can ask for an update in this function if you have such problem.
src/Core/Style.hs view
@@ -4,9 +4,9 @@ module Core.Style ( stdDims - , strkStyle , fillStyle , fullStyle + , strkStyle ) where import Text.Blaze.Svg11 ((!)) @@ -18,8 +18,11 @@ {- | `stdDims` takes some svg content and wraps it with the -`svg` tag, with attributes @viewbox="-1 -1 2 2"@, @height="300px"@ -and @width="300px"@ +@svg@ tag, with attributes: + +* @viewbox="-1 -1 2 2"@ +* @height="300px"@ +* @width="300px"@ -} stdDims :: S.Svg -> S.Svg stdDims content = @@ -32,6 +35,7 @@ {- | Handy shortcut for the following attributes: + * @fill="none"@ * @stroke="black"@ * @stroke-width="0.04"@ @@ -47,6 +51,7 @@ {- | Handy shortcut for the following attributes: + * @fill="black"@ * @stroke="none"@ * @stroke-width="0"@ @@ -62,6 +67,7 @@ {- | Handy shortcut for the following attributes: + * @fill="silver"@ * @stroke="black"@ * @stroke-width="0.03"@
src/Core/Utils.hs view
@@ -1,10 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} -{- | -Module : Core.Utils -Description : Utilities for svg coding --} + module Core.Utils ( evenOddSplit , addXmlns @@ -13,6 +10,7 @@ , horizontalMirrorMatrix , verticalMirrorMatrix , frame + , cleanDecimals ) where import Data.Char @@ -24,6 +22,7 @@ {- | Splits a list into two lists: + * The first one contains all the elements in odd positions * The second one contains all the elements in even positions -} @@ -36,6 +35,7 @@ {- | Takes some `Svg` entity and adds two attributes: + * @xmlns="http://www.w3.org/2000/svg"@ * @xmlns:xlink="http://www.w3.org/1999/xlink"@ -} @@ -50,8 +50,8 @@ {- | Handy operator that converts a `Float` number into an `AttributeValue` and feeds it to the `Attribute` function. - Example: + >S.path > ! (A.strokeWidth .: 0.1) -} @@ -73,6 +73,7 @@ {- | Matrix for the horizontal symmetry __respect to the axis @x=0@__. Use it with the transform `Attribute`: + >S.path > ! A.transform horizontalMirrorMatrix -} @@ -85,6 +86,7 @@ {- | Matrix for the vertical symmetry __respect to the axis @y=0@__. Use it with the transform `Attribute`: + >S.path > ! A.transform (verticalMirrorMatrix <> rotateAround 45 0 0) -} @@ -97,7 +99,7 @@ {- | `frame` is mainly used for testing purposes. -Takes the 4 numbers of the viewbox (x0, y0, width, height) +Takes the 4 numbers of the viewbox @(x0, y0, width, height)@ and returns a path with a very thin stroke which connects all consecutive corners of the viewbox and also connects opposite middle points. @@ -125,6 +127,9 @@ -- Takes a number n and a string s, -- and returns a string equal to s except that every decimal -- number inside s will have its decimal part capped at n digits +{- | +Please ignore this function. +-} cleanDecimals :: Int -> String -> String cleanDecimals n s = f [] [] s
src/Icons/Business.hs view
@@ -4,10 +4,10 @@ module Icons.Business ( svgBusiness - , company - , connections , analytics , bullseye + , company + , connections ) where import Text.Blaze.Svg11 ((!)) @@ -24,18 +24,18 @@ >svgBusiness :: [ (String , S.Svg) ] >svgBusiness = -> [ (,) "company" company -> , (,) "connections" connections -> , (,) "analytics" analytics +> [ (,) "analytics" analytics > , (,) "bullseye" bullseye +> , (,) "company" company +> , (,) "connections" connections > ] -} svgBusiness :: [ (String , S.Svg) ] svgBusiness = - [ (,) "company" company - , (,) "connections" connections - , (,) "analytics" analytics + [ (,) "analytics" analytics , (,) "bullseye" bullseye + , (,) "company" company + , (,) "connections" connections ] @@ -43,7 +43,9 @@ {- |  +  +  -} company :: S.Svg @@ -124,7 +126,9 @@ {- |  +  +  -} connections :: Svg @@ -184,7 +188,9 @@ {- |  +  +  -} analytics :: Svg
src/Icons/Computer.hs view
@@ -2,7 +2,18 @@ -module Icons.Computer where +module Icons.Computer + ( svgComputer + , accept + , cancel + , plus + , maximize + , minimize + , menuDots + , menuLines + , powerButton + , warning + ) where import Text.Blaze.Svg11 ((!)) import Text.Blaze.Svg11 as S @@ -18,28 +29,28 @@ >svgComputer :: [ (String , S.Svg) ] >svgComputer = -> [ (,) "plus" plus +> [ (,) "accept" accept > , (,) "cancel" cancel -> , (,) "accept" accept -> , (,) "warning" warning -> , (,) "minimize" minimize +> , (,) "plus" plus > , (,) "maximize" maximize +> , (,) "minimize" minimize > , (,) "menuDots" menuDots > , (,) "menuLines" menuLines > , (,) "powerButton" powerButton +> , (,) "warning" warning > ] -} svgComputer :: [ (String , S.Svg) ] svgComputer = - [ (,) "plus" plus + [ (,) "accept" accept , (,) "cancel" cancel - , (,) "accept" accept - , (,) "warning" warning - , (,) "minimize" minimize + , (,) "plus" plus , (,) "maximize" maximize + , (,) "minimize" minimize , (,) "menuDots" menuDots , (,) "menuLines" menuLines , (,) "powerButton" powerButton + , (,) "warning" warning ] @@ -49,7 +60,9 @@ {- |  +  +  -} plus :: Svg @@ -78,7 +91,9 @@ {- |  +  +  -} cancel :: Svg @@ -90,7 +105,9 @@ {- |  +  +  -} accept :: Svg @@ -117,7 +134,9 @@ {- |  +  +  -} warning :: Svg @@ -162,7 +181,9 @@ {- |  +  +  -} minimize :: Svg @@ -183,7 +204,9 @@ {- |  +  +  -} maximize :: Svg @@ -219,7 +242,9 @@ {- |  +  +  -} menuDots :: Svg @@ -239,7 +264,9 @@ {- |  +  +  -} menuLines :: Svg @@ -262,7 +289,9 @@ {- |  +  +  -} powerButton :: S.Svg
src/Icons/Cosmos.hs view
@@ -2,7 +2,12 @@ -module Icons.Cosmos where +module Icons.Cosmos + ( svgCosmos + , moonCrescent + , moonFull + , sun + ) where import Text.Blaze.Svg11 ((!)) import Text.Blaze.Svg11 as S @@ -18,16 +23,16 @@ >svgCosmos :: [ (String , S.Svg) ] >svgCosmos = -> [ (,) "sun" (sun 14) -> , (,) "moon" moon -> , (,) "crescent" crescent +> [ (,) "moonCrescent" moonCrescent +> , (,) "moonFull" moonFull +> , (,) "sun" (sun 14) > ] -} svgCosmos :: [ (String , S.Svg) ] svgCosmos = - [ (,) "sun" (sun 14) - , (,) "moon" moon - , (,) "crescent" crescent + [ (,) "moonCrescent" moonCrescent + , (,) "moonFull" moonFull + , (,) "sun" (sun 14) ] @@ -37,7 +42,9 @@ {- |  +  +  Takes a natural number @n@ which draws @2*n@ rays. @@ -70,12 +77,14 @@ {- | - - - + + + + + -} -moon :: Svg -moon = +moonFull :: Svg +moonFull = S.path ! A.strokeLinejoin "round" ! A.d moonDirs @@ -93,12 +102,14 @@ {- | - - - + + + + + -} -crescent :: Svg -crescent = +moonCrescent :: Svg +moonCrescent = S.path ! A.strokeLinejoin "round" ! A.d moonDirs
src/Icons/Human.hs view
@@ -2,7 +2,17 @@ -module Icons.Human where +module Icons.Human + ( svgHuman + , carnet + , eyeOpened + , eyeStriked + , heartFat + , heartSlim + , people + , person + , talk + ) where import Text.Blaze.Svg11 ((!)) import Text.Blaze.Svg11 as S @@ -17,25 +27,25 @@ >svgHuman :: [ (String , S.Svg) ] >svgHuman = -> [ (,) "eyeOpened" eyeOpened +> [ (,) "carnet" carnet +> , (,) "eyeOpened" eyeOpened > , (,) "eyeStriked" eyeStriked -> , (,) "person" person -> , (,) "people" people -> , (,) "carnet" carnet > , (,) "heartFat" heartFat > , (,) "heartSlim" heartSlim +> , (,) "people" people +> , (,) "person" person > , (,) "talk" talk > ] -} svgHuman :: [ (String , S.Svg) ] svgHuman = - [ (,) "eyeOpened" eyeOpened + [ (,) "carnet" carnet + , (,) "eyeOpened" eyeOpened , (,) "eyeStriked" eyeStriked - , (,) "person" person - , (,) "people" people - , (,) "carnet" carnet , (,) "heartFat" heartFat , (,) "heartSlim" heartSlim + , (,) "people" people + , (,) "person" person , (,) "talk" talk ] @@ -46,7 +56,9 @@ {- |  +  +  -} eyeOpened :: S.Svg @@ -91,7 +103,9 @@ {- |  +  +  -} eyeStriked :: S.Svg @@ -113,7 +127,9 @@ {- |  +  +  -} person :: S.Svg @@ -143,7 +159,9 @@ {- |  +  +  -} people :: S.Svg @@ -157,7 +175,9 @@ {- |  +  +  -} carnet :: S.Svg @@ -206,7 +226,9 @@ {- |  +  +  -} heartFat :: Svg @@ -237,7 +259,9 @@ {- |  +  +  -} heartSlim :: Svg @@ -267,7 +291,9 @@ {- |  +  +  -} talk :: Svg
src/Icons/Math.hs view
@@ -2,7 +2,11 @@ -module Icons.Math where +module Icons.Math + ( svgMath + , lambda + , lemniscate + ) where import Text.Blaze.Svg11 ((!)) import Text.Blaze.Svg11 as S @@ -35,7 +39,9 @@ {- |  +  +  -} lambda :: S.Svg @@ -83,7 +89,9 @@ {- |  +  +  -} lemniscate :: Svg
src/Icons/Office.hs view
@@ -2,7 +2,19 @@ -module Icons.Office where +module Icons.Office + ( svgOffice + , archive + , briefcase + , clipboard + , document + , envelope + , lupe + , paperclip + , pencil + , pin + , printer + ) where import Text.Blaze.Svg11 ((!)) import Text.Blaze.Svg11 as S @@ -18,30 +30,30 @@ >svgOffice :: [ (String , S.Svg) ] >svgOffice = -> [ (,) "envelope" envelope -> , (,) "pencil" pencil +> [ (,) "archive" archive +> , (,) "briefcase" briefcase +> , (,) "clipboard" clipboard > , (,) "document" document -> , (,) "archive" archive +> , (,) "envelope" envelope +> , (,) "lupe" lupe +> , (,) "paperclip" paperclip +> , (,) "pencil" pencil > , (,) "pin" pin -> , (,) "clip" paperclip -> , (,) "clipboard" clipboard > , (,) "printer" printer -> , (,) "lupe" lupe -> , (,) "briefcase" briefcase > ] -} svgOffice :: [ (String , S.Svg) ] svgOffice = - [ (,) "envelope" envelope - , (,) "pencil" pencil + [ (,) "archive" archive + , (,) "briefcase" briefcase + , (,) "clipboard" clipboard , (,) "document" document - , (,) "archive" archive - , (,) "pin" pin + , (,) "envelope" envelope + , (,) "lupe" lupe , (,) "paperclip" paperclip - , (,) "clipboard" clipboard + , (,) "pencil" pencil + , (,) "pin" pin , (,) "printer" printer - , (,) "lupe" lupe - , (,) "briefcase" briefcase ] @@ -51,7 +63,9 @@ {- |  +  +  -} envelope :: Svg @@ -81,7 +95,9 @@ {- |  +  +  -} pencil :: Svg @@ -124,7 +140,9 @@ {- |  +  +  -} document :: Svg @@ -178,7 +196,9 @@ {- |  +  +  -} archive :: S.Svg @@ -221,7 +241,9 @@ {- |  +  +  -} pin :: Svg @@ -267,7 +289,9 @@ {- |  +  +  -} paperclip :: Svg @@ -311,7 +335,9 @@ {- |  +  +  -} clipboard :: Svg @@ -355,7 +381,9 @@ {- |  +  +  -} printer :: Svg @@ -435,7 +463,9 @@ {- |  +  +  -} lupe :: S.Svg @@ -472,7 +502,9 @@ {- |  +  +  -} briefcase :: Svg
src/Icons/Religion.hs view
@@ -2,7 +2,16 @@ -module Icons.Religion where +module Icons.Religion + ( svgReligion + , xp + , taijitu + , crossLatin + , crossOrthodox + , crescentAndStar + , starOfDavid + , iChingHexagram + ) where import Data.String import Text.Blaze.Svg11 ((!)) @@ -47,7 +56,9 @@ {- |  +  +  -} xp :: Svg @@ -130,7 +141,9 @@ {- |  +  +  You must provide both yin and yang colors @@ -181,7 +194,9 @@ {- |  +  +  -} crossLatin :: Svg @@ -212,7 +227,9 @@ {- |  +  +  -} crossOrthodox :: Svg @@ -268,7 +285,9 @@ {- |  +  +  -} crescentAndStar :: Svg @@ -293,7 +312,9 @@ {- |  +  +  -} starOfDavid :: Svg @@ -304,7 +325,9 @@ {- |  +  +  Function to draw a hexagram from the Yi Ching (the Book of Mutations).
src/Icons/Textarea.hs view
@@ -2,7 +2,25 @@ -module Icons.Textarea where +module Icons.Textarea + ( svgTextarea + , bold + , italic + , link + , imageIcon + , video + , horizontalBars + , bulletList + , numberList + , header + , horizontalRule + , curvyArrowLeft + , undo + , redo + , questionMark + , fullscreen + , preview + ) where import Text.Blaze.Svg11 ((!)) import Text.Blaze.Svg11 as S @@ -60,7 +78,9 @@ {- |  +  +  -} bold :: S.Svg @@ -102,7 +122,9 @@ {- |  +  +  -} italic :: S.Svg @@ -146,7 +168,9 @@ {- |  +  +  -} link :: S.Svg @@ -181,7 +205,9 @@ {- |  +  +  -} imageIcon :: S.Svg @@ -240,7 +266,9 @@ {- |  +  +  -} video :: S.Svg @@ -308,7 +336,9 @@ {- |  +  +  -} bulletList :: S.Svg @@ -331,7 +361,9 @@ {- |  +  +  -} numberList :: Svg @@ -363,7 +395,9 @@ {- |  +  +  -} header :: S.Svg @@ -416,7 +450,9 @@ {- |  +  +  -} horizontalRule :: S.Svg @@ -475,7 +511,9 @@ {- |  +  +  -} undo :: S.Svg @@ -487,7 +525,9 @@ {- |  +  +  -} redo :: S.Svg @@ -528,7 +568,9 @@ {- |  +  +  -} questionMark :: S.Svg @@ -559,7 +601,9 @@ {- |  +  +  -} fullscreen :: S.Svg @@ -591,7 +635,9 @@ {- |  +  +  -} preview :: S.Svg
src/Icons/Tools.hs view
@@ -2,7 +2,13 @@ -module Icons.Tools where +module Icons.Tools + ( svgTools + , cogwheel + , key + , keyWithArc + , lock + ) where import Text.Blaze.Svg11 ((!)) import Text.Blaze.Svg11 as S @@ -18,20 +24,20 @@ >svgTools :: [ (String , S.Svg) ] >svgTools = -> [ (,) "lock" lock +> [ (,) "cog6" cog6 +> , (,) "cog9" cog9 > , (,) "key" key > , (,) "keyWithArc" keyWithArc -> , (,) "cog6" cog6 -> , (,) "cog9" cog9 +> , (,) "lock" lock > ] -} svgTools :: [ (String , S.Svg) ] svgTools = - [ (,) "lock" lock + [ (,) "cog6" cog6 + , (,) "cog9" cog9 , (,) "key" key , (,) "keyWithArc" keyWithArc - , (,) "cog6" cog6 - , (,) "cog9" cog9 + , (,) "lock" lock ] @@ -41,7 +47,9 @@ {- |  +  +  -} lock :: S.Svg @@ -93,7 +101,9 @@ {- |  +  +  -} key :: S.Svg @@ -129,7 +139,9 @@ {- |  +  +  -} keyWithArc :: S.Svg @@ -162,11 +174,15 @@ {- |  +  +   +  +  Takes a natural number @n@ which is the number of cogs,
svg-icons.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: svg-icons -version: 0.1.0.1 +version: 0.1.0.2 homepage: https://github.com/RamiroPastor/SvgIcons license: BSD-3-Clause license-file: LICENSE