Skip to content

Commit

Permalink
🚚 Simplify folder structure and remove unnecessary helper fn
Browse files Browse the repository at this point in the history
  • Loading branch information
FluidSense committed Aug 2, 2023
1 parent e1279ae commit a36300d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/spor-icon-elm/elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"version": "1.0.0",
"exposed-modules": [
"Spor.Icon.Icons"
"Spor.Icon"
],
"elm-version": "0.19.1 <= v < 0.20.0",
"dependencies": {
Expand Down
21 changes: 6 additions & 15 deletions packages/spor-icon-elm/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import svg2elm from 'svg2elm';
import * as svgo from 'svgo';

const svgFolder = '../spor-icon/svg';
const targetFolder = './src/Spor/Icon';
const targetFolder = './src/Spor';

const groupBy = (xs, key) => {
return xs.reduce(function(rv, x) {
Expand Down Expand Up @@ -79,11 +79,11 @@ async function generateSvgs() {
fillFunctionName: fills.find(fillSvg => fillSvg.name === svg.name) ? svg.functionName + "Fill_" : svg.functionName + "Outline_"
}))

const moduleHeader = generateModuleHeader("Icons", implementationNames.sort((a, b) => lexicalSortUniqueStrings(a.functionName, b.functionName)), uniqueIconSizes);
const moduleHeader = generateModuleHeader("Icon", implementationNames.sort((a, b) => lexicalSortUniqueStrings(a.functionName, b.functionName)), uniqueIconSizes);
const src = [moduleHeader].concat(svgImpls)
.join('\n\n\n{-|-}\n');

const targetFile = path.join(targetFolder, `Icons.elm`);
const targetFile = path.join(targetFolder, `Icon.elm`);

fs.writeFile(targetFile, src);
})
Expand Down Expand Up @@ -157,11 +157,8 @@ function generateToHtmlCase(icons) {
return `
{-| -}
toHtml : IconConfig -> Html msg
toHtml iconConfig =
let
icon_ = getIcon iconConfig
in
case icon_ of
toHtml ((IconConfig iconOptions) as iconConfig) =
case iconOptions.icon of
${icons.map(icon => `${camelCase(icon, { pascalCase: true })} ->
${icon} iconConfig
`).join("\n ")}
Expand Down Expand Up @@ -203,7 +200,7 @@ sizeToEm size =


function generateModuleHeader(moduleName, svgs, sizes) {
return `module Spor.Icon.${moduleName} exposing (toHtml, FillType(..), IconConfig, Size(..), IconVariant(..), icon, withColor)
return `module Spor.${moduleName} exposing (toHtml, FillType(..), IconConfig, Size(..), IconVariant(..), icon, withColor)
{-| ${moduleName}
Expand Down Expand Up @@ -259,12 +256,6 @@ withColor color (IconConfig config) =
{-| -}
getIcon : IconConfig -> IconVariant
getIcon (IconConfig iconConfig) =
iconConfig.icon
${sizeToEmCase(sizes)}
${generateToHtmlCase(svgs.map(svg => svg.functionName))}
Expand Down

0 comments on commit a36300d

Please sign in to comment.