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

chore: add docs with size #17279

Merged
merged 5 commits into from
Sep 25, 2023
Merged

chore: add docs with size #17279

merged 5 commits into from
Sep 25, 2023

Conversation

J-Son89
Copy link
Contributor

@J-Son89 J-Son89 commented Sep 13, 2023

Added docs for recent decision made by theme on how to handle sizes in the code base

To test:
This pr updates the use of this new api for a set of components. Nothing should change.

these components include:
Group avatar
Icon avatar

Network dropdown

Preview list

System message

Settings/ Data item

Context tag

Network tags

Number tags

Wallet keypair

@status-im-auto
Copy link
Member

status-im-auto commented Sep 13, 2023

Jenkins Builds

Click to see older builds (20)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 8f8160c #1 2023-09-13 13:26:57 ~5 min android-e2e 🤖apk 📲
✔️ 8f8160c #1 2023-09-13 13:28:04 ~6 min ios 📱ipa 📲
✔️ 8f8160c #1 2023-09-13 13:30:41 ~9 min android 🤖apk 📲
✔️ 8f8160c #1 2023-09-13 13:31:03 ~9 min tests 📄log
667a37e #2 2023-09-14 08:35:00 ~2 min tests 📄log
✔️ 667a37e #2 2023-09-14 08:37:51 ~5 min android-e2e 🤖apk 📲
✔️ 667a37e #2 2023-09-14 08:38:21 ~5 min android 🤖apk 📲
✔️ 667a37e #2 2023-09-14 08:42:53 ~10 min ios 📱ipa 📲
171b62c #3 2023-09-19 12:11:16 ~2 min tests 📄log
✔️ 171b62c #3 2023-09-19 12:14:56 ~6 min ios 📱ipa 📲
✔️ 171b62c #3 2023-09-19 12:15:22 ~6 min android 🤖apk 📲
✔️ 171b62c #3 2023-09-19 12:15:34 ~7 min android-e2e 🤖apk 📲
df2f522 #4 2023-09-25 06:36:16 ~2 min ios 📄log
df2f522 #4 2023-09-25 06:36:40 ~2 min tests 📄log
✔️ df2f522 #4 2023-09-25 06:39:36 ~5 min android-e2e 🤖apk 📲
✔️ df2f522 #4 2023-09-25 06:39:43 ~5 min android 🤖apk 📲
0cd2079 #5 2023-09-25 06:52:30 ~2 min ios 📄log
✔️ 0cd2079 #5 2023-09-25 06:55:50 ~5 min android-e2e 🤖apk 📲
✔️ 0cd2079 #5 2023-09-25 06:59:31 ~9 min android 🤖apk 📲
✔️ 0cd2079 #5 2023-09-25 06:59:48 ~9 min tests 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 5daebfe #6 2023-09-25 10:47:04 ~7 min ios 📱ipa 📲
✔️ 5daebfe #6 2023-09-25 10:49:38 ~9 min android-e2e 🤖apk 📲
✔️ 5daebfe #6 2023-09-25 10:49:45 ~10 min android 🤖apk 📲
✔️ 5daebfe #6 2023-09-25 10:50:02 ~10 min tests 📄log
✔️ 1eca41f #7 2023-09-25 11:08:10 ~6 min ios 📱ipa 📲
✔️ 1eca41f #7 2023-09-25 11:12:04 ~10 min android-e2e 🤖apk 📲
✔️ 1eca41f #7 2023-09-25 11:12:13 ~10 min android 🤖apk 📲
✔️ 1eca41f #7 2023-09-25 11:12:15 ~10 min tests 📄log


```clojure
;; good
(defn button
Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed indentation:

(defn button
  [{:keys [size]}]
  [rn/view
   {:style {:height (case size
                      20 20
                      20 40
                      0)}}]
  ...)

(defn button
  [{:keys [size]}]
  [rn/view
   {:style {:height (case size
                      :size/s-20 20
                      :size/s-40 40
                      0)}}]
  ...)

To avoid having the codebase littered with magic numbers we instead have a keyword convention
to use in components to map these keywords with their sizes.

The convention is `:sizes/s-<number>`, e.g size `20` is `:size/s-20`
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably a typo, :sizes/s-<number> => :size/s-<number>

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 a typo, thought i fixed before. Will adjust!

Copy link
Member

Choose a reason for hiding this comment

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

just wondering why s- is needed?

Copy link
Member

Choose a reason for hiding this comment

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

it's a little bit confusing, like sizes s,m,l,..etc

Copy link
Member

Choose a reason for hiding this comment

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

why not just :size-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.

Yes the exploding keywords is the purpose of /s-. If it's okay I will adjust to @flex-surfers & @ulisesmac suggestion. While the keywords are slightly magic it is a better alternative than what we had and really the best approach is for semantic names but these need to be in the design file so we're slightly too far gone from that for now.
We can of course talk to designers for this going forward.

I can make the required convention changes in the codebase in this pr

Copy link
Contributor

Choose a reason for hiding this comment

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

If it's okay I will adjust to @flex-surfers & @ulisesmac suggestion.

Sure, that and because :size/20 is considered invalid by the Clojure reader, so :size-20 is better.

Copy link
Contributor

Choose a reason for hiding this comment

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

I also dislike :size/20 or :size-20 because it's more like a glorified magic value

Yes, I think at the end it's the same as 20, I see almost the same in:

{:foo "bar"
 :size 20}

than

{:foo  "bar"
 :size :size-20}

But it's ok, I prefer :size-20 over :size/s-20 👍

Thank you so much @J-Son89 for documenting this! :) 👍 💯

Copy link
Member

Choose a reason for hiding this comment

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

thank you, guys!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, and in this pr I also changed the uses in the codebase. I think a search and replace should be safe here 👍

@@ -69,6 +69,38 @@ In the image above we can see the properties are `Type`, `State`, `Size`,
...)
```

### Handling Sizes
For sizes there is a slightly special case. In the designs, sizes are referred to as integers.
Copy link
Contributor

Choose a reason for hiding this comment

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

When reading the guideline in isolation, the first sentence seems unnecessary. We can start the paragraph with In the designs, sizes ....

Suggestion, with line breaks at 80:

In the designs, sizes are referred to as integers. To avoid having the codebase
littered with magic numbers we instead have a keyword convention to use in
components to map these keywords with their sizes.

[rn/view {:style {
:height (case size
20 20
20 40
Copy link
Member

Choose a reason for hiding this comment

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

40 40 probably? i know its just an example but anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually that's a typo 😅 thanks!

To avoid having the codebase littered with magic numbers we instead have a keyword convention
to use in components to map these keywords with their sizes.

The convention is `:sizes/s-<number>`, e.g size `20` is `:size/s-20`
Copy link
Member

Choose a reason for hiding this comment

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

just wondering why s- is needed?

To avoid having the codebase littered with magic numbers we instead have a keyword convention
to use in components to map these keywords with their sizes.

The convention is `:sizes/s-<number>`, e.g size `20` is `:size/s-20`
Copy link
Member

Choose a reason for hiding this comment

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

it's a little bit confusing, like sizes s,m,l,..etc

To avoid having the codebase littered with magic numbers we instead have a keyword convention
to use in components to map these keywords with their sizes.

The convention is `:sizes/s-<number>`, e.g size `20` is `:size/s-20`
Copy link
Member

Choose a reason for hiding this comment

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

why not just :size-20 ?

Copy link
Member

@flexsurfer flexsurfer left a comment

Choose a reason for hiding this comment

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

thanks

@flexsurfer
Copy link
Member

Would it not be better to use a qualified keyword that is dependent on the component in question?

i don't think it's worth it to give so much attention and time to this, i would leave it as is with just integers, but if we change i still prefer "global" :size-24, because it will be confusing which one you have to use with component , so as a developer i preffer the simplest one when i use component, lets say now its simple, [button {:size 24}] i don't need to think much, i know any component has size prop with int value

@ilmotta
Copy link
Contributor

ilmotta commented Sep 19, 2023

I agree with the simplicity mindset brought by @flexsurfer. At the same time, my heart goes to a codebase where pretty much all arbitrary design constants (sizes, colors, spacing, dimensions, etc) are both:

  1. Semantic
  2. Contextualized

I worked in a codebase with designers and devs respecting this approach and there's no way I prefer magic design constants everywhere like what we do in status-mobile.

BUT, going back to what @flexsurfer said, I think we shouldn't overstress these ideas, because in the end, it's the design team that would need to more or less radically change how they prefer to handle these values in the design system, and I don't think such changes are possible at this stage of the game.

@J-Son89
Copy link
Contributor Author

J-Son89 commented Sep 19, 2023

Sure, simple sounds good. 👍
@ilmotta, @flexsurfer I would have to disagree about nothing putting time into these discussions. This is the third time the approach to sizes has changed and the concerns which prompted these most recent changes have been floating around a long time.
Better to get all doubts considered before moving forward. We are 30+ devs and once an approach is agreed upon they start to get used widespread to the codebase making it very difficult to refactor at a future point.

@ilmotta
Copy link
Contributor

ilmotta commented Sep 19, 2023

Sure, simple sounds good. 👍 @ilmotta, @flexsurfer I would have to disagree about nothing putting time into these discussions. This is the third time the approach to sizes has changed and the concerns which prompted these most recent changes have been floating around a long time. Better to get all doubts considered before moving forward. We are 30+ devs and once an approach is agreed upon they start to get used widespread to the codebase making it very difficult to refactor at a future point.

@J-Son89, I approved the PR with the intention of solving the following problems:

  • Magical sizes are hard to grep and identify in the codebase, unique keywords are easily replaceable in one go.
  • Numbers are not autocompleted in editors, so using a keyword like :size-20 gives me a useful list of possible values.

Therefore, I think a global keyword like :size-20 solves the problem well.

It's a marginal improvement, but it's good nonetheless.


About contextualizing keywords, it would be good to have a separate discussion because this PR had a different scope. What problems are we trying to solve by contextualizing size keywords? We should be careful how we do this, because where before we had a single size 20 as a number, we might end up causing an explosion of keywords which can be even more error prone to maintain.

@status-im-auto
Copy link
Member

86% of end-end tests have passed

Total executed tests: 43
Failed tests: 6
Passed tests: 37
IDs of failed tests: 702732,702783,703503,702786,702731,702808 

Failed tests (6)

Click to expand
  • Rerun failed tests

  • Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_pin_messages, id: 702731
    Test is not run, e2e blocker  
    

    [[reason: [NOTRUN] Pin feature is in development]]

    Class TestCommunityMultipleDeviceMergedTwo:

    1. test_community_mentions_push_notification, id: 702786

    # STEP: Invited member gets push notification with the mention and tap it
    Device 2: Getting PN by 'user_2'

    critical/test_public_chat_browsing.py:1149: in test_community_mentions_push_notification
        self.errors.verify_no_errors()
    base_test_case.py:191: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Push notification with the mention was not received by admin
    E    Can not edit a message with a mention
    E    Push notification with the mention was not received by the invited member 
    

    [[Issue with username in PN, issue #6 in 15500]]

    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUiTwo:

    1. test_1_1_chat_is_shown_message_sent_delivered_from_offline, id: 702783

    Device 2: Find Text by xpath: //*[starts-with(@text,'test message')]/ancestor::android.view.ViewGroup[@content-desc='chat-item']//*[@content-desc='message-status']/android.widget.TextView
    Device 2: Text is Sent

    critical/chats/test_1_1_public_chats.py:1416: in test_1_1_chat_is_shown_message_sent_delivered_from_offline
        self.errors.verify_no_errors()
    base_test_case.py:191: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Message was not delivered after resending from offline
    E    Message status was not changed to Delivered, it's Sent after back up online!
    



    Device sessions

    Class TestGroupChatMultipleDeviceMergedNewUI:

    1. test_group_chat_pin_messages, id: 702732

    Test is not run, e2e blocker  
    

    [[reason: [NOTRUN] Pin feature is in development]]

    2. test_group_chat_offline_pn, id: 702808

    Device 3: Looking for a message by text: message from old member
    Device 3: Looking for a message by text: message from new member

    critical/chats/test_group_chat.py:442: in test_group_chat_offline_pn
        self.errors.verify_no_errors()
    base_test_case.py:191: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Messages PN was not fetched from offline
    



    Device sessions

    Class TestCommunityOneDeviceMerged:

    1. test_community_discovery, id: 703503

    Test is not run, e2e blocker  
    

    [[reason: [NOTRUN] https://github.com//issues/17175]]

    Passed tests (37)

    Click to expand

    Class TestActivityMultipleDevicePR:

    1. test_navigation_jump_to, id: 702936
    Device sessions

    2. test_activity_center_reply_read_unread_delete_filter_swipe, id: 702947
    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_emoji_send_reply_and_open_link, id: 702782
    Device sessions

    2. test_1_1_chat_text_message_delete_push_disappear, id: 702733
    Device sessions

    3. test_1_1_chat_push_emoji, id: 702813
    Device sessions

    4. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745
    Device sessions

    5. test_1_1_chat_edit_message, id: 702855
    Device sessions

    6. test_1_1_chat_send_image_save_and_share, id: 703391
    Device sessions

    7. test_1_1_chat_message_reaction, id: 702730
    Device sessions

    Class TestActivityCenterContactRequestMultipleDevicePR:

    1. test_activity_center_contact_request_accept_swipe_mark_all_as_read, id: 702851
    Device sessions

    2. test_activity_center_contact_request_decline, id: 702850
    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUiTwo:

    1. test_1_1_chat_delete_via_long_press_relogin, id: 702784
    Device sessions

    2. test_1_1_chat_mute_chat, id: 703496
    Device sessions

    Class TestCommunityMultipleDeviceMergedTwo:

    1. test_community_markdown_support, id: 702809
    Device sessions

    2. test_community_hashtag_links_to_community_channels, id: 702948
    Device sessions

    3. test_community_leave, id: 702845
    Device sessions

    Class TestCommunityMultipleDeviceMerged:

    1. test_community_several_images_send_reply, id: 703194
    Device sessions

    2. test_community_one_image_send_reply, id: 702859
    Device sessions

    3. test_community_emoji_send_copy_paste_reply, id: 702840
    Device sessions

    4. test_community_mark_all_messages_as_read, id: 703086
    Device sessions

    5. test_community_contact_block_unblock_offline, id: 702894
    Device sessions

    6. test_community_message_delete, id: 702839
    Device sessions

    7. test_community_message_send_check_timestamps_sender_username, id: 702838
    Device sessions

    8. test_community_links_with_previews_github_youtube_twitter_gif_send_enable, id: 702844
    Device sessions

    9. test_community_message_edit, id: 702843
    Device sessions

    10. test_community_unread_messages_badge, id: 702841
    Device sessions

    Class TestActivityMultipleDevicePRTwo:

    1. test_activity_center_mentions, id: 702957
    Device sessions

    2. test_activity_center_admin_notification_accept_swipe, id: 702958
    Device sessions

    Class TestGroupChatMultipleDeviceMergedNewUI:

    1. test_group_chat_mute_chat, id: 703495
    Device sessions

    2. test_group_chat_send_image_save_and_share, id: 703297
    Device sessions

    3. test_group_chat_reactions, id: 703202
    Device sessions

    4. test_group_chat_join_send_text_messages_push, id: 702807
    Device sessions

    Class TestCommunityOneDeviceMerged:

    1. test_restore_multiaccount_with_waku_backup_remove_switch, id: 703133
    Device sessions

    2. test_community_copy_and_paste_message_in_chat_input, id: 702742
    Device sessions

    3. test_community_undo_delete_message, id: 702869
    Device sessions

    4. test_community_navigate_to_channel_when_relaunch, id: 702846
    Device sessions

    5. test_community_mute_community_and_channel, id: 703382
    Device sessions

    @J-Son89
    Copy link
    Contributor Author

    J-Son89 commented Sep 19, 2023

    Sure, simple sounds good. 👍 @ilmotta, @flexsurfer I would have to disagree about nothing putting time into these discussions. This is the third time the approach to sizes has changed and the concerns which prompted these most recent changes have been floating around a long time. Better to get all doubts considered before moving forward. We are 30+ devs and once an approach is agreed upon they start to get used widespread to the codebase making it very difficult to refactor at a future point.

    @J-Son89, I approved the PR with the intention of solving the following problems:

    • Magical sizes are hard to grep and identify in the codebase, unique keywords are easily replaceable in one go.
    • Numbers are not autocompleted in editors, so using a keyword like :size-20 gives me a useful list of possible values.

    Therefore, I think a global keyword like :size-20 solves the problem well.

    It's a marginal improvement, but it's good nonetheless.

    About contextualizing keywords, it would be good to have a separate discussion because this PR had a different scope. What problems are we trying to solve by contextualizing size keywords? We should be careful how we do this, because where before we had a single size 20 as a number, we might end up causing an explosion of keywords which can be even more error prone to maintain.

    yes, I agree this goes beyond the initial purpose of the pr. I just didn't want to cement another decision without raising my last concern. I agree that this is not the optimal solution but a reasonable tradeoff for our current setup.
    I have pretty much 0 experience of using contextual keywords so I was deferring to you guys to get some feedback on the idea and it seems it is not worth it for this use case. So we have a decision and stick with :size-<number> 👍

    @VolodLytvynenko
    Copy link
    Contributor

    Hi @J-Son89 thank you for PR. No issues from my side. Ready to be merged

    @ulisesmac
    Copy link
    Contributor

    Hi @J-Son89 thank you for PR. No issues from my side. Ready to be merged

    @VolodLytvynenko I'm taking care of this PR since Jamie took some days off. I will merge it then 👍

    Copy link
    Contributor

    @ibrkhalil ibrkhalil left a comment

    Choose a reason for hiding this comment

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

    As always, Great work! 🚀

    @ulisesmac ulisesmac merged commit f47a4a1 into develop Sep 25, 2023
    2 checks passed
    @ulisesmac ulisesmac deleted the jc/sizes-doc branch September 25, 2023 11:22
    ibrkhalil pushed a commit that referenced this pull request Oct 1, 2023
    * chore: update guidelines for sizes
    
    * chore: update to size uses in codebase to follow new convention
    
    ---------
    
    Co-authored-by: Ulises M <ulises.ssb@hotmail.com>
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    Archived in project
    Archived in project
    Development

    Successfully merging this pull request may close these issues.