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

Custom styling #2

Open
oscarotero opened this issue Jan 27, 2022 · 4 comments
Open

Custom styling #2

oscarotero opened this issue Jan 27, 2022 · 4 comments

Comments

@oscarotero
Copy link
Contributor

Hi.
As I can see, this component use a style tag in the shadow root to apply styles and use themes to apply colors and fonts.
I recommend to use CSS ::part() pseudo selector for more flexibility and maintainability.

You can see an example of this in the oom-components/searcher web component:

This would make more easy to apply styles on different media queries, light/dark themes, etc. For example:

psyche-search::part(input) {
    border-color: var(--primary-color);
}

And it allows to combine a base theme in the shadow DOM that can be overrided by outside css.

@dragonwocky
Copy link
Owner

dragonwocky commented Jan 27, 2022

I know about ::part(), I left it out because I'm hesitant to make it fully customisable - some parts shouldn't be modified (e.g. the balance of element sizing/layout, the position:sticky behaviour of section headings and the "Search by psyche" footer link) and the component is built to be a drop-in, recognisable solution that doesn't require any user HTML/CSS to work (everything should be self-contained within the import - it's not a reuseable custom element built to follow the web component standards, it just makes use of those web APIs for convenience). You can already use custom media queries etc. to customise the themes beyond the builtin light/dark, as the variables are applied to the <psyche-search></psyche-search> element outside the shadow root.

The majority of the client is the UI, and the HTML and CSS involved are very specifically dependent on each other. I'm considering the possibility of separating out the client logic & generalising the Result interface a bit further so there could be multiple client UI options, as the current one is very heavily designed for documentation websites only. Further client customisation would probably be something I would include in that update. I've done some more testing this morning with the ::part() selector and it's more restrictive than I thought (i.e. you can't chain it with a child or sibling selector), so I'd probably include it for some but not all elements as part of that.

@oscarotero
Copy link
Contributor Author

Ok, no problem.

Yeah, ::part() is used to label specific elements and doesn't allow children selectors. This is good because you can decide which elements you want to make fully customisable and which don't.

I'd like to fix the following issue: the highlighted text is white with yellow background when the result is selected. So I don't know if there's variable in the themes object to handle this.

image

Other thing that I'd like to change is differentiate a selected element from a element with :hover:

image

@dragonwocky
Copy link
Owner

I'd like to fix the following issue: the highlighted text is white with yellow background when the result is selected. So I don't know if there's variable in the themes object to handle this.

Ah, thanks, not sure how I missed that. It's not meant to be yellow at all, I'll release a patch for that soon.

Other thing that I'd like to change is differentiate a selected element from a element with :hover:

Good idea. I'm thinking an outline for select elements and the current fill for hovered elements, I'll see how it looks when I test it.

@dragonwocky
Copy link
Owner

Those styling issues have been fixed by v0.3.2, but I'll leave this open to come back to the idea of custom styling for future updates.

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