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

UI v2 coding guidelines #3626

Open
louischan-oursky opened this issue Jan 16, 2024 · 6 comments
Open

UI v2 coding guidelines #3626

louischan-oursky opened this issue Jan 16, 2024 · 6 comments

Comments

@louischan-oursky
Copy link
Collaborator

louischan-oursky commented Jan 16, 2024

We have 2 levels of theming.

  • The first level is defined in base.css.
  • The second level is defined in the component CSS.
  • Take this as example [DEPS #4640] Implement authui v2 navbar #4662
  • --navbar__title-font-family is the second level.
  • --typography-title-large__font-family is the first level.

We borrow BEM naming convention to name the CSS variables.

  • Take this as example [DEPS #4640] Implement authui v2 navbar #4662
  • The component file called navbar.css, so the component name is navbar.
  • The CSS variables of this component must start with --navbar_.
  • You define a CSS variable for each CUSTOMISABLE property. When you are in doubt, you prefer not introducing a CSS variable. We can always add it later.
  • --navbar__some-meaningful-css-property
  • --navbar__some-meaningful-css-property--variant

Prefer tablet: over @media

HTML semantics is important.

Use gap for spacing.

See #3613 (comment)

Use ltr: and rtl: when you use explicit left/right.

See #4662 (comment)

Verbs

  • create, delete, change, view
  • add, remove, change, view

Always think about when the case when javascript is disabled

panic with error

Instead of panic("some string"), panic(fmt.Errorf("some string")). The rationale is that when you are the person who recover(), you want to get an error instead of a string. You can further call errors.As and errors.Is or any other errors processing functions on the recovered error.

@louischan-oursky louischan-oursky pinned this issue Jan 16, 2024
@louischan-oursky
Copy link
Collaborator Author

@louischan-oursky
Copy link
Collaborator Author

@tung2744 @IniZio @Ngkaokis Added Point 11.

@louischan-oursky
Copy link
Collaborator Author

Added Point 12.

Copy link
Member

fungc-io commented Mar 4, 2024

@louischan is this documented? can I close it?

@louischan-oursky
Copy link
Collaborator Author

Let me close this. We can refer to this issue when we need it in the future.

@rickmak
Copy link
Member

rickmak commented Aug 29, 2024

We should move the agreed content to CONTRIBUTING.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants