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

Create a dedicated CSS file for customization #23

Open
wants to merge 1 commit into
base: sc
Choose a base branch
from

Conversation

luixxiul
Copy link

@luixxiul luixxiul commented Mar 2, 2024

When it comes to custom styling, basically we could just import a custom CSS file after the last existing @import on _components.pcss and put every custom stuff like CSS declarations and variables in it to let them override the inherited values in the way which the concept of CSS expects. In order to achieve it, the commit of this PR updates rethemendex.sh, so that any CSS files in _sc/ folder are excluded from being included to alphabetic sorting which causes cascading mess, ensuring _customization.pcss is imported at the end of the file.

The obvious merit of doing so is that it will remove the burden of applying customization directly on the upstream CSS codebase fixing conflicts. Separating custom styles from the upstream codebase should also greatly reduce the manpower to rebase, without using screenshot tests and without being worried about possible visual regressions which may be prone to be caused due to the upstream's CSS codebase structure. Doing so will also make it easier to fix the regressions on our codebase which the upstream project has not fixed yet. Additionally, it will make contributing easier for those who would like to contribute but are not familiar with the style codebase for SchildiChat, like me.

Even if declarations are flagged with !important by the upstream to cover a new regression, it will be possible to override them with ours flagged with !important on our custom CSS files.

The way in which the upstream project generates concatenated CSS files has been very stable (essentially same since at least 2018. See: https://github.com/matrix-org/matrix-react-sdk/commits/develop/res/css/rethemendex.sh), so we should be able to depend on the current way how it works for a reasonable time.

Signed-off-by: Suguru Hirahara [email protected]


  • I agree to release my changes under this project's license


For customization, import a custom CSS file on `res/css/_sc/_customization.pcss` and put anything such as custom CSS declarations and variables in it to let them override the values inherited from the upstream.

Please mind where to import a new CSS file. **Never sort the files alphabetically as it breaks how styles cascade.**
Copy link
Author

@luixxiul luixxiul Mar 3, 2024

Choose a reason for hiding this comment

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

The general rule would be:

  • the less @import, the better
  • Import CSS files for general rules at first, then for specific ones later. Mind the order of specificity as much as possible
  • Add a detailed comment for each @import about the reason why it should be imported at the specific place, unless the reason is very clear.

When it comes to custom styling, basically we could just import a custom CSS file after the last existing `@import` on _components.pcss and put every custom stuff like CSS declarations and variables in it to let them override the inherited values in the way which the concept of CSS expects. In order to achieve it, this commit updates rethemendex.sh, so that any CSS files in _sc/ folder are excluded from being included to alphabetic sorting which causes cascading mess, ensuring _customization.pcss is imported at the end of the file.

The obvious merit of doing so is that it will remove the burden of applying customization directly on the upstream CSS codebase fixing conflicts. Separating custom styles from the upstream codebase should also greatly reduce the manpower to rebase, without being worried about possible regressions. Doing so will also make it easier to fix the regressions on our codebase which the upstream project has not fixed yet. Additionally, it will make contributing easier for those who would like to contribute but are not familiar with the style codebase for SchildiChat, like me.

Even if declarations are flagged with !important by the upstream to cover a new regression, it will be possible to override them with ours flagged with !important on our custom CSS files.

The way in which the upstream project generates concatenated CSS files has been very stable (essentially same since at least 2018. See: https://github.com/matrix-org/matrix-react-sdk/commits/develop/res/css/rethemendex.sh), so we should be able to depend on the current way how it works for a reasonable time.

Signed-off-by: Suguru Hirahara <[email protected]>
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

Successfully merging this pull request may close these issues.

1 participant