-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
231 additions
and
227 deletions.
There are no files selected for viewing
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
55 changes: 44 additions & 11 deletions
55
src/quo2/components/settings/category/component_spec.cljs
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,20 +1,53 @@ | ||
(ns quo2.components.settings.category.component-spec | ||
(:require [test-helpers.component :as h] | ||
[quo2.components.settings.category.view :as category])) | ||
(:require | ||
[quo2.components.settings.category.view :as category] | ||
[test-helpers.component :as h])) | ||
|
||
(h/describe "category tests" | ||
(h/describe "Settings Category tests" | ||
(h/test "category label renders" | ||
(h/render [category/category | ||
{:label "label" | ||
:data [{:title "Item 1" | ||
:left-icon :i/browser | ||
:chevron? true}]}]) | ||
{:list-type :settings | ||
:label "Label" | ||
:data [{:title "Item 1" | ||
:left-icon :i/browser | ||
:chevron? true}]}]) | ||
(h/is-truthy (h/get-by-text "label"))) | ||
|
||
(h/test "category item renders" | ||
(h/render [category/category | ||
{:label "label" | ||
:data [{:title "Item 1" | ||
:left-icon :i/browser | ||
:chevron? true}]}]) | ||
{:list-type :settings | ||
:label "Label" | ||
:data [{:title "Item 1" | ||
:left-icon :i/browser | ||
:chevron? true}]}]) | ||
(h/is-truthy (h/get-by-text "Item 1")))) | ||
|
||
|
||
(h/describe "Reorder Category tests" | ||
(h/test "category label renders" | ||
(h/render [category/category | ||
{:list-type :reorder | ||
:label "Label" | ||
:data [{:title "Item 1" | ||
:left-icon :i/browser | ||
:chevron? true}]}]) | ||
(h/is-truthy (h/get-by-text "label"))) | ||
|
||
(h/test "category item renders" | ||
(h/render [category/category | ||
{:list-type :reorder | ||
:label "Label" | ||
:data [{:title "Item 1" | ||
:left-icon :i/browser | ||
:chevron? true}]}]) | ||
(h/is-truthy (h/get-by-text "Item 1"))) | ||
|
||
(h/test "category item subtitle renders" | ||
(h/render [category/category | ||
{:list-type :reorder | ||
:label "Label" | ||
:data [{:title "Item 1" | ||
:subtitle "subtitle" | ||
:left-icon :i/browser | ||
:chevron? true}]}]) | ||
(h/is-truthy (h/get-by-text "subtitle")))) |
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,40 @@ | ||
(ns quo2.components.settings.category.reorder.view | ||
(:require | ||
[quo2.components.markdown.text :as text] | ||
[quo2.components.settings.reorder-item.types :as types] | ||
[quo2.components.settings.reorder-item.view :as reorder-item] | ||
[quo2.foundations.colors :as colors] | ||
[react-native.blur :as blur] | ||
[react-native.core :as rn] | ||
[quo2.components.settings.category.style :as style] | ||
[quo2.theme :as quo.theme] | ||
[react-native.draggable-flatlist :as draggable-flatlist] | ||
[reagent.core :as reagent])) | ||
|
||
(defn on-drag-end-fn | ||
[data atom-data] | ||
(reset! atom-data data) | ||
(reagent/flush)) | ||
|
||
(defn- reorder-category-internal | ||
[{:keys [label data blur? theme]}] | ||
(reagent/with-let [atom-data (reagent/atom data)] | ||
[rn/view {:style style/container} | ||
(when blur? | ||
[rn/view (style/blur-container) [blur/view (style/blur-view)]]) | ||
[text/text | ||
{:weight :medium | ||
:size :paragraph-2 | ||
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}} | ||
label] | ||
[draggable-flatlist/draggable-flatlist | ||
{:data @atom-data | ||
:key-fn (fn [item index] (str (:title item) index)) | ||
:style (style/reorder-items theme blur?) | ||
:render-fn (fn [item _ _ _ _ drag] [reorder-item/reorder-item item types/item blur? drag]) | ||
:on-drag-end-fn (fn [_ _ data] | ||
(on-drag-end-fn data atom-data)) | ||
:separator [rn/view | ||
{:style (style/reorder-separator blur?)}]}]])) | ||
|
||
(def reorder-category (quo.theme/with-theme reorder-category-internal)) |
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,27 @@ | ||
(ns quo2.components.settings.category.settings.view | ||
(:require | ||
[quo2.components.markdown.text :as text] | ||
[quo2.components.settings.settings-list.view :as settings-list] | ||
[quo2.foundations.colors :as colors] | ||
[react-native.blur :as blur] | ||
[react-native.core :as rn] | ||
[quo2.components.settings.category.style :as style] | ||
[quo2.theme :as quo.theme])) | ||
|
||
(defn- category-internal | ||
[{:keys [label data blur? theme]}] | ||
[rn/view {:style style/container} | ||
(when blur? | ||
[rn/view (style/blur-container) [blur/view (style/blur-view)]]) | ||
[text/text | ||
{:weight :medium | ||
:size :paragraph-2 | ||
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}} | ||
label] | ||
[rn/flat-list | ||
{:data data | ||
:style (style/settings-items theme blur?) | ||
:render-fn (fn [item] [settings-list/settings-list item]) | ||
:separator [rn/view {:style (style/settings-separator theme blur?)}]}]]) | ||
|
||
(def settings-category (quo.theme/with-theme category-internal)) |
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 |
---|---|---|
@@ -1,27 +1,9 @@ | ||
(ns quo2.components.settings.category.view | ||
(:require | ||
[quo2.components.markdown.text :as text] | ||
[quo2.components.settings.settings-list.view :as settings-list] | ||
[quo2.foundations.colors :as colors] | ||
[react-native.blur :as blur] | ||
[react-native.core :as rn] | ||
[quo2.components.settings.category.style :as style] | ||
[quo2.theme :as quo.theme])) | ||
(:require [quo2.components.settings.category.settings.view :as settings] | ||
[quo2.components.settings.category.reorder.view :as reorder])) | ||
|
||
(defn- category-internal | ||
[{:keys [label data blur? theme]}] | ||
[rn/view {:style style/container} | ||
(when blur? | ||
[rn/view (style/blur-container) [blur/view (style/blur-view)]]) | ||
[text/text | ||
{:weight :medium | ||
:size :paragraph-2 | ||
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}} | ||
label] | ||
[rn/flat-list | ||
{:data data | ||
:style (style/items theme blur?) | ||
:render-fn (fn [item] [settings-list/settings-list item]) | ||
:separator [rn/view {:style (style/separator theme blur?)}]}]]) | ||
|
||
(def category (quo.theme/with-theme category-internal)) | ||
(defn category | ||
[{:keys [list-type] :as props}] | ||
(if (= list-type :settings) | ||
[settings/settings-category props] | ||
[reorder/reorder-category props])) |
1 change: 0 additions & 1 deletion
1
src/quo2/components/settings/reorder_category/component_spec.cljs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
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
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
Oops, something went wrong.