Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add title input component to quo2 #15133

Merged
merged 1 commit into from
Mar 11, 2023
Merged

feat: add title input component to quo2 #15133

merged 1 commit into from
Mar 11, 2023

Conversation

J-Son89
Copy link
Contributor

@J-Son89 J-Son89 commented Feb 19, 2023

fixes: #15159

implemented quo2 component for profile input.
dark placeholder focused
Screenshot 2023-02-19 at 22 01 43
dark placeholder not focused (blur)
Screenshot 2023-02-19 at 22 01 36
dark text completely filled in
Screenshot 2023-02-19 at 22 01 19
Screenshot 2023-02-19 at 22 00 56
Screenshot 2023-02-19 at 22 00 26
Screenshot 2023-02-19 at 22 00 05

@status-im-auto
Copy link
Member

status-im-auto commented Feb 19, 2023

Jenkins Builds

Click to see older builds (33)
Commit #️⃣ Finished (UTC) Duration Platform Result
beb5753 #1 2023-02-19 22:13:31 ~2 min tests 📄log
✔️ beb5753 #1 2023-02-19 22:18:35 ~7 min ios 📱ipa 📲
✔️ beb5753 #1 2023-02-19 22:18:42 ~7 min android-e2e 🤖apk 📲
✔️ beb5753 #1 2023-02-19 22:18:53 ~7 min android 🤖apk 📲
2a13fe5 #2 2023-03-03 13:36:37 ~2 min tests 📄log
✔️ 2a13fe5 #2 2023-03-03 13:41:29 ~7 min android-e2e 🤖apk 📲
✔️ 2a13fe5 #2 2023-03-03 13:42:05 ~8 min android 🤖apk 📲
✔️ 2a13fe5 #2 2023-03-03 13:45:06 ~11 min ios 📱ipa 📲
58443b5 #4 2023-03-03 13:58:34 ~4 min tests 📄log
✔️ 58443b5 #4 2023-03-03 14:01:45 ~7 min ios 📱ipa 📲
✔️ 58443b5 #4 2023-03-03 14:02:34 ~8 min android 🤖apk 📲
✔️ 58443b5 #4 2023-03-03 14:02:53 ~8 min android-e2e 🤖apk 📲
cd16b05 #5 2023-03-03 23:01:10 ~12 sec ios 📄log
cd16b05 #5 2023-03-03 23:01:11 ~13 sec android 📄log
cd16b05 #5 2023-03-03 23:01:11 ~13 sec android-e2e 📄log
cd16b05 #5 2023-03-03 23:01:24 ~25 sec tests 📄log
✔️ 629b902 #6 2023-03-03 23:36:22 ~4 min tests 📄log
✔️ 629b902 #6 2023-03-03 23:39:28 ~7 min ios 📱ipa 📲
✔️ 629b902 #6 2023-03-03 23:40:07 ~7 min android 🤖apk 📲
✔️ 629b902 #6 2023-03-03 23:42:12 ~9 min android-e2e 🤖apk 📲
✔️ 9995729 #7 2023-03-06 11:06:39 ~4 min tests 📄log
✔️ 9995729 #7 2023-03-06 11:09:33 ~7 min ios 📱ipa 📲
✔️ 9995729 #7 2023-03-06 11:10:08 ~8 min android-e2e 🤖apk 📲
✔️ 9995729 #7 2023-03-06 11:10:13 ~8 min android 🤖apk 📲
a191675 #8 2023-03-08 15:43:07 ~2 min tests 📄log
✔️ a191675 #8 2023-03-08 15:48:18 ~7 min ios 📱ipa 📲
✔️ a191675 #8 2023-03-08 15:48:21 ~7 min android-e2e 🤖apk 📲
✔️ a191675 #8 2023-03-08 15:49:10 ~8 min android 🤖apk 📲
27c6259 #9 2023-03-10 10:26:22 ~1 min tests 📄log
79daa93 #10 2023-03-10 10:34:14 ~3 min tests 📄log
✔️ 79daa93 #10 2023-03-10 10:38:50 ~7 min ios 📱ipa 📲
✔️ 79daa93 #10 2023-03-10 10:39:39 ~8 min android-e2e 🤖apk 📲
✔️ 79daa93 #10 2023-03-10 10:40:09 ~9 min android 🤖apk 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ fb76551 #11 2023-03-10 11:12:48 ~4 min tests 📄log
✔️ fb76551 #11 2023-03-10 11:16:21 ~7 min android-e2e 🤖apk 📲
✔️ fb76551 #11 2023-03-10 11:16:28 ~8 min android 🤖apk 📲
✔️ fb76551 #11 2023-03-10 11:17:05 ~8 min ios 📱ipa 📲
✔️ cc069a8 #12 2023-03-11 16:20:04 ~4 min tests 📄log
✔️ cc069a8 #12 2023-03-11 16:22:39 ~6 min ios 📱ipa 📲
✔️ cc069a8 #12 2023-03-11 16:23:36 ~7 min android-e2e 🤖apk 📲
✔️ cc069a8 #12 2023-03-11 16:23:53 ~8 min android 🤖apk 📲

max-length 24
on-change-text (fn [v]
(reset! value v)
(reagent/flush)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without reagent/flush the text flickers on input..

researched this here:
reagent-project/reagent#485 (comment)

Should we take a different approach for input components, I see quo text inputs are quite complicated although perhaps this is necessary for a smooth input effect.

In any case we should probably have the base functionality available for all input components and then we can stylise the ui as needed for the various components.

Would appreciate some input (🤓) on this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:default-value should be used, we shouldn't pass any value to the input

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you mean? surely the on change has to pass the updated value to the reset function ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://gist.github.com/ilmotta/9753c003359bda9be2afd85d4e4a78d9

@J-Son89, see the gist I created now. I tested now and it works correctly. It follows some of the suggestions by @flexsurfer

@J-Son89 J-Son89 self-assigned this Feb 19, 2023
(ns quo2.components.inputs.title-input.style
(:require [quo2.foundations.colors :as colors]))


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra line

[disabled? blur?]
{:color (when disabled? (get-disabled-color blur?))})


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra line

max-length 24
on-change-text (fn [v]
(reset! value v)
(reagent/flush)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:default-value should be used, we shouldn't pass any value to the input


(defn- pad-0
[value]
(if (<= (count value) 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not sure this is needed, i guess its just in design for the demo purposes, there is an example 5/24 and there is no leading zero

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I meant 9. it should always be two digits. e.g 05/24 or 03/09 etc
Will check again to make sure it's right 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to ask in figma, to make sure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I will double check with design team 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: If we want to format with leading zeros, in CLJS we should probably use format:

(goog.string/format "%02d" 9) ; => 09

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilmotta, this caused issues with the component tests. The compiler makes goog a global object so it doesn't play so nice with the tests. There's most likely a way to set this up, and something we will definitely need to address at some point.
For now I left is as I would prefer to keep the tests on this and it's only some basic functionality but I will spend some time looking into how we can work with goog imports and component tests.

TypeError: goog.string.format is not a function

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem then, thanks for the info. It could be a good idea to create a quick issue if we haven't one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sure I can create an issue for this 👍

:on-change-text on-change-text
:disabled? (:disabled? @state)
:blur? (:blur? @state)
:placeholder "type something here"} @value]]]])))
Copy link
Member

@flexsurfer flexsurfer Feb 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i mean here, we shouldn't pass @value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, that seems strange to me. is there not times then when the ui and data is out of sync?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be :default-value @value

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, that seems strange to me. is there not times then when the ui and data is out of sync?

why strange? why would you want to set value ? it was already set when you pressed the key

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @flexsurfer

Just to make more clear the explanation:

[my-text-component
 {:on-change     #(reset! @value,,,) ;; <- or any other function you want
  :default-value @value ;; <- this could be useful to initialize the field
                        ;; with a specified value, but it's not required
  :value         @value ;; <- you set this only if you manually want to update
                        ;; component's value. e.g. you have a "clear" button that
                        ;; when pressed it resets the atom to "", if you don't
                        ;; specify `:value @value`, then your change will not be
                        ;; reflected on the input.
  }]

@ulisesmac
Copy link
Contributor

Hey @J-Son89
Will you create the whole component for this PR? (i.e. the card containing the profile picture and this input).

@ulisesmac
Copy link
Contributor

Hey @J-Son89 Will you create the whole component for this PR? (i.e. the card containing the profile picture and this input).

I'm sorry, I thought you were implementing the "Profile Input" component instead of "Title Input".
Probably we should not directly link this PR to the issue Implement quo2 component - Inputs/ Profile Input #15020 to avoid confusion

Copy link
Contributor

@ulisesmac ulisesmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @J-Son89 I added some small comments, the component looks good!

@@ -39,6 +39,14 @@
(alpha light-color light-opacity)
(alpha dark-color dark-opacity))))))

(defn theme-color-with-blur
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about adding this abstraction 🤔

AFAIK, we don't dinamically change from blur colors to non-blur colors as we do with dark and light colors.

I've seen the usages in your component's styles and it looks good, but I would first put it as a helper function in your style namespace, if the patttern is repeated more often in other components, then add to a more general namespace (such as foundations/colors).

My main concern is that function could lead to the understanding that we dinamically change from blur to non-blur colors and it could easlily be rewritten from:

(defn- get-char-count-color
  [blur?]
  (colors/theme-color-with-blur
   blur?
   colors/neutral-40
   (colors/alpha colors/neutral-80 0.4)
   colors/neutral-50
   (colors/alpha colors/white 0.4)))

to:

(defn- get-char-count-color
  [blur?]
  (if blur?
    (colors/theme-colors (colors/alpha colors/neutral-80 0.4) (colors/alpha colors/white 0.4))
    (colors/theme-colors colors/neutral-40 colors/neutral-50)))

Would be nice to have input from other members :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, I've just seen across multiple components where we have 4 variations of colors (light, dark, light +blur, dark + blur).
It's pretty common across the designs really, see "src/quo2/components/selectors/styles.cljs" and it could use this function there.

Re: "AFAIK, we don't dinamically change from blur colors to non-blur colors as we do with dark and light colors."
Not sure what you mean by - dynamically changing color sets?

most of the blur variations have their own colors than their respective light or dark non blur implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but yep, happy to adjust this helper and also localize it to this style file if other devs see this to be the case too 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean by - dynamically changing color sets?

I mean, a component using (theme-colors light-color dark-color) will return light-color or dark-color depending on user preferences (dinamically).

But we won't swap between a light-color and a blur-light-color, I mean, a component using a blur color will always use a blur color, and it'll swap between blur-light-color and blur-dark-color which is already covered by the theme-colors fn.

[rn/view
{:style style/container}
[rn/view
[rn/text-input
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cursor's color is different when we change the theme and blur variants:
(blue, black and white, for example):
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen some problems while testing on Android: Pixel4 API 30:

image
the sentence is incomplete but there is still room for it to fit.

  1. It seems "00/24" is a little lower than the designs, but IDK whether this is related to the implementation or phone's font size
    image
    image

  2. A strange "." appears in the placeholder after you write:
    Screencast from 2023-02-21 14-22-57.webm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will take a look, think I need to re-approach that alignment. Will adjust the cursor too!

@J-Son89
Copy link
Contributor Author

J-Son89 commented Feb 22, 2023

Hey @J-Son89 Will you create the whole component for this PR? (i.e. the card containing the profile picture and this input).

I'm sorry, I thought you were implementing the "Profile Input" component instead of "Title Input". Probably we should not directly link this PR to the issue Implement quo2 component - Inputs/ Profile Input #15020 to avoid confusion

yep, my bad. I thought I had created the other issue. Created the correct issue and adjusted the link!

[rn/view {:flex 1}]
[preview/customizer state descriptor]
[rn/view
{:padding-vertical 60
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No big deal, but these props should be inside the :style map.

Copy link
Contributor Author

@J-Son89 J-Son89 Feb 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes,I will add this and separate into view/style files.

I think we should note however that none of the other preview screens have followed this best practice so far, not even new ones.

Ideally we will move preview screens to a better tool (most likely Storybook ) in which case these files will all be removed, and we can clean up the preview screens code somewhat at the same time too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've attempted once to add Storybook to status-mobile, but never really got it to a decent state to share. Would love to see progress in this area too.

:size :paragraph-2} (pad-0 (str (count value)))]
[text/text
{:style (style/char-count blur?)
:size :paragraph-2} (str "/" (pad-0 (str max-length)))]]]])))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(colors/theme-color-with-blur
blur?
colors/neutral-30
(colors/alpha colors/neutral-80 0.2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not colors/neutral-80-opa-20?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will adjust

:flex 1}
[rn/flat-list
{:flex 1
:keyboardShouldPersistTaps :always
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be kebab-case?

@J-Son89 J-Son89 force-pushed the jc/title-input branch 3 times, most recently from b15aa82 to 58443b5 Compare March 3, 2023 13:53

(defn- pad-0
[value]
(if (<= (count value) 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: If we want to format with leading zeros, in CLJS we should probably use format:

(goog.string/format "%02d" 9) ; => 09

{:label "Cursor Color"
:key :color
:type :select
:options (map (fn [color] (let [key (get color :name)] {:key key :value key}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One-liners can easily become unreadable in Lisps, because we lose track of the code (also data) structure. I don't know about you folks, but I find the code below more readable.

(map (fn [color]
       (let [key (get color :name)]
         {:key key :value key}))
     (quo/picker-colors))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@J-Son89 this may squeak by as a one-liner :)

(map (fn [{:keys [name]}] {:key name :value name}) (quo/picker-colors))

:customization-color (:color @state)
:blur? (:blur? @state)
:placeholder "type something here"}]]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra lines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad 😅

:style (style/title-text disabled? blur?)})
:default-value default-value
:accessibility-label :profile-title-input
:on-focus #(swap! focused? not)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't :on-focus be #(reset! focused? true) and :on-blur be #(reset! focused? false) ? For example, in which situation would we want to have focused? true if the input is not focused and vice-versa?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah better to be safe about this 👍

@J-Son89 J-Son89 force-pushed the jc/title-input branch 2 times, most recently from cd16b05 to 629b902 Compare March 3, 2023 23:31
@@ -116,6 +116,20 @@ deref'ed atoms.
{:background-color (colors/theme-colors colors/white colors/neutral-90)})
```

### Custom Colors

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Parveshdhull updated the docs for customization color :)

@J-Son89 J-Son89 force-pushed the jc/title-input branch 2 times, most recently from 9995729 to a191675 Compare March 8, 2023 15:40
@J-Son89 J-Son89 force-pushed the jc/title-input branch 2 times, most recently from 27c6259 to 79daa93 Compare March 10, 2023 10:30
@J-Son89
Copy link
Contributor Author

J-Son89 commented Mar 10, 2023

@ulisesmac I updated my changes with this branch so the preview screen should be correct on android now

Copy link
Contributor

@ulisesmac ulisesmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Jaime!
It looks very good! :)

@J-Son89 J-Son89 merged commit d8c110b into develop Mar 11, 2023
@J-Son89 J-Son89 deleted the jc/title-input branch March 11, 2023 16:29
alwx pushed a commit that referenced this pull request Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

implement quo2 component - inputs / title input
7 participants