-
-
Notifications
You must be signed in to change notification settings - Fork 399
Custom CSS classes #1757
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
Custom CSS classes #1757
Conversation
|
Thanks @srt19170 I'll try to review this ASAP! |
|
Thank you for this PR! I've left a few notes below. Please keep in mind that once we introduce custom CSS classes, users will expect them to remain supported in future releases, so we need to balance the benefit of each new class against the cost of maintaining it over time.
|
|
Thanks for taking a look at this! Obviously this is your project and you get to decide, but here are some thoughts on the issues:
Initially I intended to only add class-names to "significant" UI elements but I realized that one of my existing rules used an "insignificant" element, so I ended up erring on the side of completeness and gave a name to everything. I wasn't sure there's much of a maintenance issue after the initial change. I don't imagine you'll often change the meaning of a UI element, and everything have a unique name means you can change the structure without breaking most of the custom CSS. But maybe there's something I'm missing.
Well, the names are really just arbitrary, so if we can come up with semantic names that's fine. I initially started out trying to use semantic names but I ran into things like cf-FeedEntryHeader-Flex1-Flex-Box where it was getting difficult to come up with meaningful names for all the nested elements. The utility of this naming was that I could look at the generated HTML and trace an element name back to the source code where it appeared, but that's probably more useful to creating the class names than to using them.
I thought about this but my concern was that it will make the UI brittle to structural changes, i.e., if for some reason you drop the Box after cf-FeedEntries you will break all the path references under the Box. (In fact, that's what set me down this path in the first place. I had custom CSS that of necessity used a lot of long paths and which broke when something fairly high up in the hierarchy was changed.) So I thought that giving every element a unique name would make custom CSS more resilient to most code changes.
Yeah, as I was slogging through all those pages I had my doubts! Mostly I did them for the sake of completeness. I certainly have no need of them. |
|
Would you willing to share your custom CSS code? It would help me get a better understanding of what kind of customization you're doing 🙂 |
|
My current custom CSS is basically what's in the example in the documentation file. If you have a way to put a call out to people asking for their custom code or for comments on this change that would be good. Maybe people who have opened CSS issues? |
|
I've reviewed your custom CSS and pushed a commit to this branch with changes I'm more comfortable with going forward. For example, some of your previous selectors can now be written as such:
Let me know what you think! |
|
Will you be documenting the new .cf classes? I think having some kind of guide to the CSS classes would be helpful to anyone who wants to develop custom CSS. Tagging a few other custom CSS users: @DarkFox, @Lorentz83, @Crul, @sn0crash |
I created this branch mainly to get some feedback, I think it strikes a middle ground between the current code and what you proposed in this PR. I wanted to check if you were able to achieve the customization you had in mind with these changes. If it fits your needs, then adding documentation indeed makes sense 😊 |
|
It's a little difficult to recreate my custom CSS without the new class names and a mapping to the old class names or at least the parts of the interface. When I have time I can try to go through the code and the HTML and recreate my changes but it might be a while before I can find the time, sorry! But I'm sure its possible so if you're happy with this version don't wait on my feedback. |
|
I was thinking about this a bit more from the aspect of "make it easy for the most common changes". To do that, you want to give the custom CSS authors easy anchors for the most common kinds of changes. In that light, I think you want to have simple anchors to the following parts of the main UI page:
Notes:
I hope this is helpful! |
|
Hi @srt19170, sorry for the delay. Let me know if anything's still missing, otherwise I'll go ahead and merge the branch and close this PR. |
|
Seems great! Let me know if you want me to help create the documentation or anything. |
|
Great! I just merged the branch. If you could update the documentation you wrote in this PR, I’d really appreciate it. Thanks! |
|
I've updated the documentation to reflect the current code. I've updated my branch, but I'll attach it here since it might be easier just to grab the file here. Note you'll need to link it into the documentation somewhere. |
The documentation is now available here and there are references to that url in the README and next to the custom CSS editor. Thank you! |
In this fork, I've added custom CSS classes to most of the CommaFeed page elements. For example, the header of a feed entry is enclosed in an HTML
<div>element with the class namecf-FeedEntryHeader. This makes writing custom CSS easier; for example, if you want to make change the background color of the headers, you could add this to the custom CSS code:The class names are hierarchical, so a name like
cf-FeedEntryHeader-Flex1-Flex-Boxrefers (reading right to left) to a Box element within a Flex element within another Flex element within the cf-FeedEntryHeader element. The elements within these class names (e.g., Box, Flex, etc.) follow the naming scheme in the CommaFeed source code (and hence, the naming scheme in the Mantine library. The actual HTML elements in the rendered page are often different. For example, a Mantine Box element becomes an HTML<div>.I've also created a .md file documenting all of the custom class names, and modified README.md to reference that file. The documentation also includes an extended example of custom CSS. I've put that file in the home directory.