commit eb0e736a2ff840b94bbca2bc8c988aaa91dcf3dc Author: Emi Simpson Date: Tue Feb 1 17:33:58 2022 -0500 Basic elm functionality diff --git a/elm.json b/elm.json new file mode 100644 index 0000000..44db396 --- /dev/null +++ b/elm.json @@ -0,0 +1,25 @@ +{ + "type": "application", + "source-directories": [ + "src" + ], + "elm-version": "0.19.1", + "dependencies": { + "direct": { + "elm/browser": "1.0.2", + "elm/core": "1.0.5", + "elm/html": "1.0.0", + "rtfeldman/elm-sorter-experiment": "2.1.1" + }, + "indirect": { + "elm/json": "1.1.3", + "elm/time": "1.0.0", + "elm/url": "1.0.0", + "elm/virtual-dom": "1.0.2" + } + }, + "test-dependencies": { + "direct": {}, + "indirect": {} + } +} diff --git a/src/Main.elm b/src/Main.elm new file mode 100644 index 0000000..0cf7645 --- /dev/null +++ b/src/Main.elm @@ -0,0 +1,69 @@ +module Main exposing (main) + +import Browser +import Sort.Set exposing (Set) +import Html exposing (Html, div, input, label, p, text, h3) +import Html.Events exposing (onCheck) +import Html.Attributes exposing (class, type_) +import Modules exposing + ( Module + , all_modules + , module_property + , module_desc + , module_sorter + ) + +main: Program () Model Msg +main = + Browser.sandbox { init = init, update = update, view = view } + +-- INIT + Model + + +type alias Model = + { enabled_modules : Set Module + } + +init : Model +init = + { enabled_modules = Sort.Set.empty module_sorter + } + +-- UPDATE + +type Msg + = ToggleModule Module Bool + +add_or_remove : Bool -> (a -> Set a -> Set a) +add_or_remove active = + if active then + Sort.Set.insert + else + Sort.Set.remove + +update : Msg -> Model -> Model +update msg model = + case msg of + ToggleModule mod enabled -> + { model | enabled_modules = add_or_remove enabled mod model.enabled_modules } + +-- VIEW + +view_module_button : Set Module -> Module -> Html Msg +view_module_button enabled mod = + label + (if Sort.Set.memberOf enabled mod then [class "active"] else []) + [ input + [ type_ "checkbox" + , onCheck (ToggleModule mod) + ] [] + , h3 [] [ text (module_property .name mod) ] + , p [] (module_desc mod) + ] + +view : Model -> Html Msg +view model = + div [] ( + all_modules + |> List.map (view_module_button model.enabled_modules) + ) diff --git a/src/Modules.elm b/src/Modules.elm new file mode 100644 index 0000000..a6eaf9c --- /dev/null +++ b/src/Modules.elm @@ -0,0 +1,247 @@ +module Modules exposing + ( Module + , all_modules + , ModuleInfo + , module_info + , module_property + , module_desc + , module_sorter + ) + +import Html exposing (Html, text, a) +import Html.Attributes exposing (href) +import Sort exposing (Sorter) + +type Module + = CarbonUnderground + | Ecocide + | Extractive + | BDS + | Taliban + | Myanmar + | XinjiangUygar + | UsTariff + | Surveillance + | Military + | LawEnforcement + | Media + | SocialAuditing + | BoardOfDirectors + | SupplyChain + | Copyleft + +all_modules : List Module +all_modules = + [ CarbonUnderground + , Ecocide + , Extractive + , BDS + , Taliban + , Myanmar + , XinjiangUygar + , UsTariff + , Surveillance + , Military + , LawEnforcement + , Media + , SocialAuditing + , BoardOfDirectors + , SupplyChain + , Copyleft + ] + +type alias ModuleInfo = + { name: String + , desc: List (Html Never) + , index: Int + } + +module_info : Module -> ModuleInfo +module_info mod = case mod of + CarbonUnderground -> + { name = "Carbon Underground 200" + , desc = + [ text + """ + Disallow use by the top global publicly-owned coal, oil, and gas reserve (judged + by + """ + , a + [ href "https://www.ffisolutions.com/research-analytics-index-solutions/research-screening/the-carbon-underground-200/" + ] + [ text "the FFI Carbon Underground 200)" ] + ] + , index = 0 + } + Ecocide -> + { name = "Ecocide" + , desc = [text "Disallow anyone who knowingly commits widespread or long term ecocide"] + , index = 1 + } + Extractive -> + { name = "Extractive Industries" + , desc = + [text + """ + Disallow use by anyone involved in fossil fuel / mineral exploitation, + extraction, development, and sale + """ + ] + , index = 2 + } + BDS -> + { name = "BDS (Boycott, Divestment, Sanctions)" + , desc = + [ text "Disallow use by anyone on the " + , a + [ href "https://bdsmovement.net/" ] + [ text "Boycott, Divestment, Sanctions'" ] + , text "list" + ] + , index = 3 + } + Taliban -> + { name = "Taliban" + , desc = [text "Disallow use by anyone who trades with, works with, or is the Taliban"] + , index = 4 + } + Myanmar -> + { name = "Myanmar" + , desc = + [ text + """ + Disallow use by anyone who trades with, works with, or is the Myanmar/Burmese + military + """ + ] + , index = 5 + } + XinjiangUygar -> + { name = "Xinjiang Uygur Autonomous Region" + , desc = + [ text + """ + Disallow use by anyone who works with or is someone who benefits from goods + produced in the Xinjiang Uygur Autonomous Region of China + """ + ] + , index = 6 + } + UsTariff -> + { name = "U.S. Tariff Act" + , desc = + [ text + """ + Disallow use by anyone who works with or is someone who the U.S. Customs and + Border Protection believes uses forced labor + """ + ] + , index = 7 + } + Surveillance -> + { name = "Mass Surveillance" + , desc = + [ text + """ + Disallow use by anyone who works with or is a goverment/multinational corporation + who participates in a mass-surveilence program + """ + ] + , index = 8 + } + Military -> + { name = "Military Activities" + , desc = + [ text + """ + Disallow use by anyone who works with or is a goverment/multinational corporation + who conducts military activities + """ + ] + , index = 9 + } + LawEnforcement -> + { name = "Law Enforcement" + , desc = + [ text + """ + Disallow use by anyone who works with or anyone who trades with or offers support + to local, state, or federal law enforcement + """ + ] + , index = 10 + } + Media -> + { name = "Media" + , desc = + [ text + """ + Disallow use by anyone who is or works with someone who broadcasts messages + promoting violence + """ + ] + , index = 11 + } + SocialAuditing -> + { name = "Social Auditing" + , desc = + [ text + """ + Require that organizations that use your software only use social auditing methods + that adhere to the principles of the + """ + , a + [ href "https://wsr-network.org/what-is-wsr/statement-of-principles/" ] + [ text "Worker-Driven Social Responsibility Network," ] + , text + """ + or not use social auditing methods at all + """ + ] + , index = 12 + } + BoardOfDirectors -> + { name = "Workers on Board of Directors" + , desc = + [ text + """ + If the organization using your software has a board of directors, require that + they have at least 30% of the seats on the board be paid less than twice the + amount of the the lowest paid worker in the organization + """ + ] + , index = 13 + } + SupplyChain -> + { name = "Supply Chain Transparency" + , desc = + [ text + """ + Require that whoever uses your software must publish information about their + supply chain on a public website + """ + ] + , index = 14 + } + Copyleft -> + { name = "Copyleft" + , desc = + [ text + """ + Require that any modifications or derivitive works based on your software or + source code be licensed under the exact same license + """ + ] + , index = 15 + } + +module_property : (ModuleInfo -> a) -> Module -> a +module_property adapter mod = adapter (module_info mod) + +module_desc : Module -> List (Html a) +module_desc mod = + module_property .desc mod + |> List.map (Html.map never) + +module_sorter : Sorter Module +module_sorter = Sort.by (module_property .index) Sort.increasing