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

Refactor templates to use classes instead of inline style tags #36

Open
etrepum opened this issue Aug 14, 2019 · 2 comments
Open

Refactor templates to use classes instead of inline style tags #36

etrepum opened this issue Aug 14, 2019 · 2 comments

Comments

@etrepum
Copy link
Member

etrepum commented Aug 14, 2019

For example:

Now:

<div style="text-align: center">
  <div style="display: inline-block" class="mui-panel"></div>
</div>

Desired:

<div class="notifications-container">
  <div class="mui-panel"></div>
</div>

Elsewhere in a <style> tag or included .css file:

.notification-container {
  text-align: center;
}

.notification-container > .mui-panel {
  display: inline-block
}

The reason to do it this way is it's easier to maintain a consistent style across pages, and it can eliminate a lot of redundancy. Once you give semantic class names to the structure of the document you can re-use them across multiple pages and restyle them all by editing the common CSS, rather than finding a whole bunch of unrelated style attributes in multiple documents and changing them all consistently.

style attributes should only really be used if necessary, e.g. dynamically setting the position of an element with some javascript (which is the kind of thing that you almost never need, some combination of flex and/or grid can do just about any layout). Mixing and matching them can cause issues with specificity since style attributes have a very high weight.

@tylerIams
Copy link
Member

tylerIams commented Aug 14, 2019 via email

@etrepum etrepum mentioned this issue Aug 14, 2019
6 tasks
@etrepum
Copy link
Member Author

etrepum commented Aug 14, 2019

It's ok to open pull requests for things that are not ready to merge yet to get early feedback. GitHub even added draft pull requests for this purpose: https://github.blog/2019-02-14-introducing-draft-pull-requests/

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

2 participants