{"id":22062766,"url":"https://github.com/ryan-haskell/css-in-elm","last_synced_at":"2025-05-12T23:05:20.198Z","repository":{"id":180159134,"uuid":"664701684","full_name":"ryan-haskell/css-in-elm","owner":"ryan-haskell","description":"Write normal CSS, then generate an Elm module with all your class names.","archived":false,"fork":false,"pushed_at":"2023-07-10T17:24:54.000Z","size":9,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-12T23:05:09.611Z","etag":null,"topics":["codegen","css","elm"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@ryannhg/css-in-elm","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryan-haskell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-07-10T14:55:51.000Z","updated_at":"2024-09-09T17:58:09.000Z","dependencies_parsed_at":"2024-03-12T23:29:57.700Z","dependency_job_id":null,"html_url":"https://github.com/ryan-haskell/css-in-elm","commit_stats":null,"previous_names":["ryannhg/css-in-elm","ryan-haskell/css-in-elm"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryan-haskell%2Fcss-in-elm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryan-haskell%2Fcss-in-elm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryan-haskell%2Fcss-in-elm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryan-haskell%2Fcss-in-elm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryan-haskell","download_url":"https://codeload.github.com/ryan-haskell/css-in-elm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253837405,"owners_count":21971983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codegen","css","elm"],"created_at":"2024-11-30T18:26:49.316Z","updated_at":"2025-05-12T23:05:20.145Z","avatar_url":"https://github.com/ryan-haskell.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @ryannhg/css-in-elm\n\u003e Write normal CSS, then generate an Elm module with all your class names.\n\n## Installation\n\n```sh\nnpm install -g @ryannhg/css-in-elm\n```\n\n## Usage\n\n### Build command\n\nGenerates an `.elm` file once, then exits\n\n```sh\n# css-in-elm build \u003cinput\u003e \u003coutput\u003e\ncss-in-elm build main.css dist/Css.elm\n```\n\n### Watch command\n\nGenerates an `.elm` file once, then listens for changes in the\ninput file, rerunning as edits come in!\n\n```sh\n# css-in-elm watch \u003cinput\u003e \u003coutput\u003e\ncss-in-elm watch main.css dist/Css.elm\n```\n\n\n## How it works\n\n1. Your CSS file is parsed into a list of class names\n\n    ```css\n    .row {\n      display: flex;\n    }\n\n    .gap-sm { gap: 0.5rem; }\n    .gap-md { gap: 1rem; }\n    .gap-lg { gap: 2rem; }\n    ```\n\n    ```js\n    [ \"row\", \"gap-sm\", \"gap-md\", \"gap-lg\" ]\n    ```\n2. Those classnames become functions in a generated Elm module\n\n    ```elm\n    -- 🤖 Generated by @ryannhg/css-in-elm ✨ --\n\n\n    module Css exposing (row, gap_sm, gap_md, gap_lg)\n\n    import Html\n    import Html.Attributes\n\n\n    row : Html.Attribute msg\n    row =\n        Html.Attributes.class \"row\"\n\n\n    gap_sm : Html.Attribute msg\n    gap_sm =\n        Html.Attributes.class \"gap-sm\"\n\n    -- ...\n\n    ```\n\n3. You can import those generated functions instead of using `String` values directly.\n\n    ```elm\n    -- BEFORE\n    import Html exposing (..)\n    import Html.Attributes exposing (class)\n\n    main =\n        div [ class \"row gap-lg\" ] [ text \"Hello!\" ]\n    ```\n\n    ```elm\n    -- AFTER\n    import Css exposing (..)\n    import Html exposing (..)\n\n    main =\n        div [ row, gap_lg ] [ text \"Hello!\" ]\n    ```\n\n4. If you delete a CSS class later, the Elm compiler will remind you to remove the usage.\n\n    ```txt\n    -- NAMING ERROR --------------------------------------- src/Main.elm\n\n    I cannot find a `gap_lg` variable:\n\n    5|     div [ row, gap_lg ] [ text \"Hello!\" ]\n                      ^^^^^^\n    These names seem close though:\n\n        gap_md\n        gap_sm\n        label\n        map\n\n    Hint: Read \u003chttps://elm-lang.org/0.19.1/imports\u003e to see how `import`\n    declarations work in Elm.\n\n    ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryan-haskell%2Fcss-in-elm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryan-haskell%2Fcss-in-elm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryan-haskell%2Fcss-in-elm/lists"}