-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from Confidenceman02/virtual-scroll-multi-var…
…iant Virtual scroll multi variant
- Loading branch information
Showing
10 changed files
with
279 additions
and
38 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Geora components</title><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="description" content="Elm select"><meta name="author" content="Geora"><link rel="stylesheet" href="index.91cabaa0.css"></head><body> <main></main> <script type="module" src="index.75a13ff1.js"></script> </body></html> | ||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Geora components</title><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="description" content="Elm select"><meta name="author" content="Geora"><link rel="stylesheet" href="index.18782437.css"></head><body> <main></main> <script type="module" src="index.5d2c5749.js"></script> </body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,35 @@ | ||
{ | ||
"type": "application", | ||
"source-directories": ["src"], | ||
"elm-version": "0.19.1", | ||
"dependencies": { | ||
"direct": { | ||
"Confidenceman02/elm-select": "10.4.3", | ||
"dtwrks/elm-book": "1.4.2", | ||
"elm/browser": "1.0.2", | ||
"elm/core": "1.0.5", | ||
"elm/html": "1.0.0", | ||
"rtfeldman/elm-css": "18.0.0" | ||
"type": "application", | ||
"source-directories": [ | ||
"src" | ||
], | ||
"elm-version": "0.19.1", | ||
"dependencies": { | ||
"direct": { | ||
"Confidenceman02/elm-select": "11.0.0", | ||
"dtwrks/elm-book": "1.4.2", | ||
"elm/browser": "1.0.2", | ||
"elm/core": "1.0.5", | ||
"elm/html": "1.0.0", | ||
"rtfeldman/elm-css": "18.0.0" | ||
}, | ||
"indirect": { | ||
"dillonkearns/elm-markdown": "7.0.1", | ||
"elm/json": "1.1.3", | ||
"elm/parser": "1.1.0", | ||
"elm/regex": "1.0.0", | ||
"elm/svg": "1.0.1", | ||
"elm/time": "1.0.0", | ||
"elm/url": "1.0.0", | ||
"elm/virtual-dom": "1.0.3", | ||
"elm-community/list-extra": "8.7.0", | ||
"pablohirafuji/elm-syntax-highlight": "3.5.0", | ||
"robinheghan/murmur3": "1.0.0", | ||
"rtfeldman/elm-hex": "1.0.0" | ||
} | ||
}, | ||
"indirect": { | ||
"dillonkearns/elm-markdown": "7.0.1", | ||
"elm/json": "1.1.3", | ||
"elm/parser": "1.1.0", | ||
"elm/regex": "1.0.0", | ||
"elm/svg": "1.0.1", | ||
"elm/time": "1.0.0", | ||
"elm/url": "1.0.0", | ||
"elm/virtual-dom": "1.0.3", | ||
"elm-community/list-extra": "8.7.0", | ||
"pablohirafuji/elm-syntax-highlight": "3.5.0", | ||
"robinheghan/murmur3": "1.0.0", | ||
"rtfeldman/elm-hex": "1.0.0" | ||
"test-dependencies": { | ||
"direct": {}, | ||
"indirect": {} | ||
} | ||
}, | ||
"test-dependencies": { | ||
"direct": {}, | ||
"indirect": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
module MultiVirtual exposing (..) | ||
|
||
import Browser | ||
import Css | ||
import Html.Styled as Styled exposing (Html, div) | ||
import Html.Styled.Attributes as StyledAttribs | ||
import Select exposing (MenuItem, initState, selectIdentifier, update) | ||
|
||
|
||
type Msg | ||
= SelectMsg (Select.Msg Int) | ||
|
||
|
||
type alias Model = | ||
{ selectState : Select.State | ||
, items : List (MenuItem Int) | ||
, selectedItems : List Int | ||
} | ||
|
||
|
||
init : ( Model, Cmd Msg ) | ||
init = | ||
( { selectState = initState (selectIdentifier "SingleSelectExample") | ||
, items = | ||
List.range 0 1000 | ||
|> List.map | ||
(\i -> | ||
Select.basicMenuItem { item = i, label = String.fromInt i } | ||
) | ||
, selectedItems = [] | ||
} | ||
, Cmd.none | ||
) | ||
|
||
|
||
main : Program () Model Msg | ||
main = | ||
Browser.element | ||
{ init = always init | ||
, view = view >> Styled.toUnstyled | ||
, update = update | ||
, subscriptions = \_ -> Sub.none | ||
} | ||
|
||
|
||
update : Msg -> Model -> ( Model, Cmd Msg ) | ||
update msg model = | ||
case msg of | ||
SelectMsg sm -> | ||
let | ||
( maybeAction, selectState, cmds ) = | ||
Select.update sm model.selectState | ||
|
||
updatedSelectedItems = | ||
case maybeAction of | ||
Just (Select.Select i) -> | ||
model.selectedItems ++ [ i ] | ||
|
||
Just (Select.Deselect deletedItems) -> | ||
List.filter (\i -> not (List.member i deletedItems)) model.selectedItems | ||
|
||
Just Select.Clear -> | ||
[] | ||
|
||
_ -> | ||
model.selectedItems | ||
in | ||
( { model | selectState = selectState, selectedItems = updatedSelectedItems }, Cmd.map SelectMsg cmds ) | ||
|
||
|
||
view : Model -> Html Msg | ||
view m = | ||
let | ||
toMenuItem item = | ||
Select.basicMenuItem { item = item, label = String.fromInt item } | ||
in | ||
div | ||
[ StyledAttribs.css | ||
[ Css.marginTop (Css.px 20) | ||
, Css.width (Css.pct 50) | ||
, Css.marginLeft Css.auto | ||
, Css.marginRight Css.auto | ||
] | ||
] | ||
[ Styled.map SelectMsg <| | ||
Select.viewVirtual | ||
(Select.multiVirtual (List.map toMenuItem m.selectedItems) | ||
|> Select.state m.selectState | ||
|> Select.menuItemsVirtual (Select.virtualFixedMenuItems 35 m.items) | ||
|> Select.placeholder "Placeholder" | ||
|> Select.searchable True | ||
|> Select.clearable True | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters