{"id":30742352,"url":"https://github.com/jamesgary/elm-config-ui","last_synced_at":"2025-10-20T15:08:30.008Z","repository":{"id":52694763,"uuid":"187196612","full_name":"jamesgary/elm-config-ui","owner":"jamesgary","description":"Config editor for elm","archived":false,"fork":false,"pushed_at":"2021-04-20T20:18:02.000Z","size":522,"stargazers_count":27,"open_issues_count":3,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2023-08-08T20:39:25.921Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elm","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jamesgary.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-17T10:25:56.000Z","updated_at":"2023-04-19T02:02:11.000Z","dependencies_parsed_at":"2022-08-22T06:40:25.026Z","dependency_job_id":null,"html_url":"https://github.com/jamesgary/elm-config-ui","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"purl":"pkg:github/jamesgary/elm-config-ui","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesgary%2Felm-config-ui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesgary%2Felm-config-ui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesgary%2Felm-config-ui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesgary%2Felm-config-ui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamesgary","download_url":"https://codeload.github.com/jamesgary/elm-config-ui/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesgary%2Felm-config-ui/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273539314,"owners_count":25123499,"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","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-09-04T02:00:47.221Z","updated_at":"2025-10-20T15:08:24.961Z","avatar_url":"https://github.com/jamesgary.png","language":"Elm","funding_links":[],"categories":["Elm"],"sub_categories":[],"readme":"# elm-config-gui\n\n## ⚠️ Note: Experimental, and likely to change! ⚠️\n\nHave a bunch of magic numbers you want to tweak in the browser? Tired of making a `Msg` for every single field? Try `elm-config-gui`!\n\n`elm-config-gui` adds a mini-editor into the browser to let you update values (`Int`, `Float`, `String`, and `Color`) on the fly without refreshing. Check out a live example [here](https://elm-boids-demo.s3-us-west-1.amazonaws.com/index.html)!\n\n![Screenshot of boids with elm-config-ui](https://user-images.githubusercontent.com/386075/64661773-dcba6a80-d3fa-11e9-96fa-d5013e0ae9e3.png)\n\nThis package has the following features:\n\n- Mini-editor in the browser to let you update config values on the fly without refreshing\n- Automatically save changes to localStorage\n- Encodes config data to JSON so you can save in a more persistent `.json` file\n\nThis module has a **javascript dependency** that sets up webcomponents for saving to localstorage and handling pointerlock for infinite dragging. It also uses a **CLI tool** for generating your `Config.elm` file. Check out the examples directory to see how it all works!\n\nThis is meant to be used a dev-facing tool. Hence, there's limited customizability for things like the view. For a fully customizable editor with things like advanced validation and types, feel free to fork and modify!\n\n# Install\n\nLet's say you want a config record that looks like this:\n\n```elm\ntype alias Config =\n  { headerFontSize : Int\n  , bodyFontSize : Int\n  , backgroundColor : Color\n  }\n```\n\nHere are the steps to wire everything up:\n\n## Step 1: Generate your `Config.elm`\n\nWhen adding a new field, such as `headerFontColor`, you'd normally have to update the `type alias Config`, add it to the form in the view, add a `Msg`, encoder, decoder, etc. Turns out there's a lot to do, which can slow down development! If you want all this generated for you, you can instead write a schema file:\n\n```elm\nmodule ConfigSchema exposing (main)\n\nimport ConfigFormGenerator exposing (Kind(..))\nimport Html exposing (Html)\n\nmyConfigFields : List ( String, Kind )\nmyConfigFields =\n    [ ( \"Header Font Size\", IntKind \"headerFontSize\" )\n    , ( \"Body Font Size\", IntKind \"bodyFontSize\" )\n    , ( \"Background Color\", ColorKind \"backgroundColor\" )\n    -- add more fields here\n    ]\n\nmain : Html msg\nmain =\n    let\n        generatedElmCode =\n            ConfigFormGenerator.toFile myConfigFields\n\n        _ =\n            Debug.log generatedElmCode \"\"\n    in\n    Html.text \"\"\n```\n\nCopy this and save it as `ConfigSchema.elm`. You can now run the following to generate a `Config.elm` file:\n\n```sh\n# Compile schema file to tmp js\nelm make ConfigSchema.elm --output=~tmp/tmp.js \u003e /dev/null\n\n# Run compiled js with node, which logs out generated elm code, and save to Config.elm:\nnode ~tmp/tmp.js \u003e Config.elm 2\u003e/dev/null\n\n# You now have a Config.elm file!\n```\n\nThis will watch for changes to `ConfigSchema.elm` and generate a `Config.elm` file with all the expanded `Config`, `empty`, and `logics` code.\n\nCheck out the `run.sh` scripts in the examples to see how to set up a watcher to do this for you automatically!\n\n## Step 2: App initialization\n\nInitialize your elm app using the `elm-config-ui-helper.js` script:\n\n```html\n\u003c!-- index.html --\u003e\n\n\u003cdiv id=\"elm\"\u003e\u003c/div\u003e\n\n\u003c!-- your compiled elm code --\u003e\n\u003cscript src=\"./main.js\"\u003e\u003c/script\u003e\n\n\u003c!-- elm-config-ui helper js --\u003e\n\u003c!-- Copy from https://github.com/jamesgary/elm-config-ui/blob/master/elm-config-ui-helper.js --\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/gh/jamesgary/elm-config-ui@f5200e/elm-config-ui-helper.js\"\u003e\u003c/script\u003e\n\n\u003cscript\u003e\n  ElmConfigUi.init({\n    // This is where you'll persist your config data for other users.\n    // It's fine if this file has just an empty object for now, like \"{}\".\n    filepath: \"./config.json\",\n    localStorageKey: \"my_app\",\n    callback: function(elmConfigUiData) {\n      // start main Elm app\n      let app = Elm.Main.init({\n        node: document.getElementById(\"elm\"),\n        flags: elmConfigUiData,\n      });\n    }\n  });\n\u003c/script\u003e\n```\n\n`elmConfigUiData` will contain json from your file and your localstorage.\n\n## Step 3: Elm app integration\n\n```elm\n-- import your generated Config file and the ConfigForm package\nimport Config exposing (Config)\nimport ConfigForm exposing (ConfigForm)\n\n-- add config and configForm to your model\ntype alias Model =\n    { ...\n    -- config is your generated config record,\n    -- which can be called like model.config.headerFontSize\n    , config : Config\n    -- configForm is an opaque type that is managed by ConfigForm\n    , configForm : ConfigForm\n    }\n\ninit : Json.Encode.Value -\u003e ( Model, Cmd Msg )\ninit elmConfigUiFlags =\n    let\n        -- Initialize your config and configForm,\n        -- passing in defaults for any empty config fields\n        ( config, configForm ) =\n            ConfigForm.init\n                { flags = elmConfigUiFlags\n                , logics = Config.logics\n                , emptyConfig =\n                    Config.empty\n                        { int = 1\n                        , float = 1\n                        , string = \"SORRY IM NEW HERE\"\n                        , bool = True\n                        , color = Color.rgba 1 0 1 1 -- hot pink!\n                        }\n                }\n    in\n    ( { config = config\n      , configForm = configForm\n      }\n    , Cmd.none\n    )\n\ntype Msg\n    = ConfigFormMsg (ConfigForm.Msg Config)\n    | ...\n\nupdate : Msg -\u003e Model -\u003e ( Model, Cmd Msg )\nupdate msg model =\n    case msg of\n        ConfigFormMsg configFormMsg -\u003e\n            let\n                ( newConfig, newConfigForm ) =\n                    ConfigForm.update\n                        Config.logics\n                        model.config\n                        model.configForm\n                        configFormMsg\n            in\n            ( { model\n                | config = newConfig\n                , configForm = newConfigForm\n              }\n            , Cmd.none\n            )\n\n-- Lastly, lets add the form to the view!\nview : Model -\u003e Html Msg\nview model =\n    Html.div\n        -- some nice styles to render it on the right side of the viewport\n        [ style \"padding\" \"12px\"\n        , style \"background\" \"#eec\"\n        , style \"border\" \"1px solid #444\"\n        , style \"position\" \"absolute\"\n        , style \"height\" \"calc(100% - 80px)\"\n        , style \"right\" \"20px\"\n        , style \"top\" \"20px\"\n        ]\n        [ ConfigForm.view\n            ConfigForm.viewOptions\n            Config.logics\n            model.configForm\n            |\u003e Html.map ConfigFormMsg\n\n        -- As a developer, you'll want to save your tweaks to your config.json.\n        -- You can copy/paste the content from this textarea to your config.json.\n        -- Then the next time a new user loads your app, they'll see your updated config.\n        , Html.textarea []\n            [ ConfigForm.encode model.configForm\n                |\u003e Json.Encode.encode 2\n                |\u003e Html.text\n            ]\n        ]\n```\n\n# Todo\n\nNew features\n\n- Undo/redo\n- Reset to default\n- Indicator for vals that differ from file (or that are entirely new)\n- Save scrolltop\n- Fancy (or custom) kinds, like css or elm-ui attributes?\n\nOptimizations\n\n- Cleaner run script (remove duplication and tmp file?)\n\nTests!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamesgary%2Felm-config-ui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamesgary%2Felm-config-ui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamesgary%2Felm-config-ui/lists"}