-
Notifications
You must be signed in to change notification settings - Fork 215
feat: add SCSS theme with css variables support #367
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
Conversation
@@ -118,7 +118,7 @@ export class SplitAreaDirective implements OnInit, OnDestroy { | |||
}) | |||
|
|||
const iframeFixDiv = this.renderer.createElement('div') | |||
this.renderer.addClass(iframeFixDiv, 'iframe-fix') | |||
this.renderer.addClass(iframeFixDiv, 'as-iframe-fix') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This a breaking change but seems more correct... @beeman worth it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding both while we are on v17.x.x with a deprecation warning, then removing it for v18?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a bit of a gray area... We never explicitly said this is public api. I think if we are going the deprecation route - just stay with it as it is now because it is not explicitly public api so no real need for the as
prefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say, do the change. We can put a small piece of description in the release notes that we renamed a private part of the API. I would not count that as a breaking change. more a "breakingish?" one? (aka a note
in the release notes)
Ok, I reviewed this. |
The PR had three main goals:
Using only css variables means the scss goes back to the component. In order to answer goal 3 I need to make the area a component instead of a directive (which I think is a good idea anyway). So my take on what's needed here:
What's your take on it? Might even eliminate the breaking changes here aside from the iframe fix naming. |
@all-contributors please add @Harpush for code |
I've put up a pull request to add @Harpush! 🎉 |
@Harpush could you update your branch with the latest changes. |
@Harpush for now, I would like to see:
I might update this after I spend some time in the code. |
What does css theme file means? A file with |
@SanderElias could you elaborate your ideas here? |
@Harpush are you waiting on feedback off @SanderElias ? |
Yes I am. Not sure I entirely understand what he asked for |
So what's the status of this PR @SanderElias @Jefiozie? Been stuck for some time now |
@Harpush I'm Sorry. I was otherwise engaged, and this slipped my attention for way too long. |
You are right about the component, but that would be a big, breaking change. About the inline templates to external files, I have a slight preference for keeping them inline. That also tends to keep the template parts smaller, which is better for a library. But if working with external templates works better for you, I would accept a PR that does that.
The I see us moving to CSS so we don't oppose SCSS to users. Our Theme should be easily usable for all users, including those who are not using SCSS. |
@SanderElias Concerning directive vs component - as we are not using standalone components/directives I believe 99% of the users will not observe a breaking change. If by any chance someone uses the attribute selector there will be a breaking change here - though I am not sure how many actually use it. The only 100% non breaking option seems like keeping the ng deep while still moving to css variables. And a later breaking PR to migrate the directive to a component and get rid of the ng deep. Another option is doing it all in one breaking PR for v18. Do keep note that ditching scss entirely is something even angular material haven't done yet. |
@Harpush, we can export a centralized 'as-split-styles' file. Ultimately, it doesn't matter where the definition lives as long as it is there. |
Oh, I have read it back, and I might be a bit unclear. |
@SanderElias how about declaring the default variables using scss variables and each component or directive that needs them will import the variables file (library internal). It will still have zero effect on users and will make a bit more sense as there is a disconnected file just for variables. The downside is the defaults which are used more than once will be duplicated after compilation and there are two names to use (scss one and css one). The thing is I am not sure if a css variables file can be imported safely to all components and directives without duplicates or whether angular can include that file without end user intervention. Adding it in the angular split main component is a bit weird if we ever have other top level components as I guess it won't apply to them? And even if it will - it isn't very clear... |
What do you mean by this? You don't need to import CSS variables. You define them once in the top component. (if we ever need to export multiple of those, we can deal with it then). That component needs to have |
If we put aside multiple top level components then putting it inside the main component does make sense. Anyway I think the directive should be a component - the only question is when (this PR vs a later breaking PR). |
|
@SanderElias
|
@Harpush I'm going to look into it, I'll let you know. |
@Harpush I did a quick test here: https://github.com/angular-split/angular-split/tree/test_css_encap_none. |
@SanderElias I didn't say it won't work. And no need for ng-deep entirely. I will push an updated version with encapsulation none. |
@SanderElias Are you sure |
Hmm, yes, I did this before, but I would use internal CSS vars and put in a fallback value in there. example: as-split {
--_as-padding: var(--as-padding, 1rem);
--_as-color: var(--as-color, gray)
/* rest of styling */
}
/* can do, but not needed anymore: */
:root {
:where(as-split) {
--as-padding: 1rem;
--as-color: gray;
}
} This makes it a bit easier for us I suspect. Wherever you need a custom thing, you use one of those |
The reason :where seems to not work id because each The private variables will work though they too will be redeclared on each |
That impact will be minimal and will be inside the CSS layer of the browser, not affecting anything on the main thread. |
@SanderElias I pushed the changes. A few notes:
|
@Harpush I reviewed your code, and do like most of it. Also, you have variable names that end with That would look something like: @property --as-gutter-icon-horizontal {
syntax: "<URL>";
inherits: true;
initial-value:
url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==');
} Here is the CSS, without the need for additional processing: as-split {
--_as-gutter-background-color: var(--as-gutter-background-color, #eeeeee);
--_as-gutter-icon-horizontal-bg-image-url: var(
--as-gutter-icon-horizontal-bg-image-url,
url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==')
);
--_as-gutter-icon-vertical-bg-image-url: var(
--as-gutter-icon-vertical-bg-image-url,
url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAFCAMAAABl/6zIAAAABlBMVEUAAADMzMzIT8AyAAAAAXRSTlMAQObYZgAAABRJREFUeAFjYGRkwIMJSeMHlBkOABP7AEGzSuPKAAAAAElFTkSuQmCC')
);
--_as-gutter-icon-disabled-bg-image-url: var(
--as-gutter-icon-disabled-bg-image-url,
url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==')
);
--_as-transition-duration: var(--as-transition-duration, 0.3s);
--_as-gutter-disabled-cursor: var(--as-gutter-disabled-cursor, default);
}
as-split {
display: flex;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: stretch;
overflow: hidden;
width: 100%;
height: 100%;
/* Add transition only when transition enabled + split initialized + not currently dragging. */
&.as-transition.as-init:not(.as-dragging) {
& > .as-split-gutter,
& > .as-split-area {
transition: flex-basis var(--_as-transition-duration);
}
}
& > .as-split-gutter {
border: none;
flex-grow: 0;
flex-shrink: 0;
background-color: var(--_as-gutter-background-color);
display: flex;
align-items: center;
justify-content: center;
&.as-split-gutter-collapsed {
flex-basis: 1px !important;
pointer-events: none;
}
& > .as-split-gutter-icon {
width: 100%;
height: 100%;
background-position: center center;
background-repeat: no-repeat;
}
}
& > .as-split-area {
flex-grow: 0;
flex-shrink: 0;
overflow-x: hidden;
overflow-y: auto;
&.as-hidden {
/* When <as-split-area [visible]="false"> force size to 0. */
flex: 0 1 0px !important;
overflow-x: hidden;
overflow-y: hidden;
}
& > .as-iframe-fix {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
}
&.as-horizontal {
flex-direction: row;
& > .as-split-gutter {
flex-direction: row;
cursor: col-resize;
/* Fix safari bug about gutter height when direction is horizontal. */
height: 100%;
& > .as-split-gutter-icon {
background-image: var(--_as-gutter-icon-horizontal-bg-image-url);
}
}
& > .as-split-area {
height: 100%;
}
}
&.as-vertical {
flex-direction: column;
& > .as-split-gutter {
flex-direction: column;
cursor: row-resize;
width: 100%;
& > .as-split-gutter-icon {
background-image: var(--_as-gutter-icon-vertical-bg-image-url);
}
}
& > .as-split-area {
width: 100%;
&.as-hidden {
max-width: 0;
}
}
}
&.as-disabled {
& > .as-split-gutter {
cursor: var(--_as-gutter-disabled-cursor);
& > .as-split-gutter-icon {
background-image: var(--_as-gutter-icon-disabled-bg-image-url);
}
}
}
} (if you prefer I can push this change into this branch?) |
@SanderElias May I ask why are you against scss? For public API I understand as some people don't wish to use it. But why not internally?
Concerning shortening the names - I like the Concerning the css properties - generally a good idea too but where to put it? You mentioned export css but who will import it? If the user I guess that's a breaking change? Also is there a way to define syntax for cursor? |
@Harpush Because SCSS doesn't add anything anymore, it just takes additional build time.
Name one. I wouldn't know about any that would have an impact. And when that is the case, we should utilize POSTCSS anyway.
Hmm, Angular does, based on the browsersList. But aside from that, it has been chrome since V112, and without the
It should be in a CSS file we distribute. People who want to use the theme's can then optionally import this. If they don't everything will still work as expected. However authoring the CSS where you want to set our vars would benefit. |
@SanderElias |
I would say it can be used with |
@SanderElias So I made a little test. Seems this can work: What do you think? The only downside is the initial value (default). In |
@Harpush The fallback needs to be in the component anyway! When a browser doesn't support |
I reverted back to the default values in the component. |
@SanderElias this one can be merged,right? |
Yes |
Adds support for SCSS theme with all options as CSS variables too.
Closes #331
Closes #248