Skip to content

Commit

Permalink
Remove tint layer => use color-mix() now
Browse files Browse the repository at this point in the history
  • Loading branch information
lucsoft committed Jul 20, 2024
1 parent 1ee457b commit a4db09b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
20 changes: 1 addition & 19 deletions src/components/Layer.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,15 @@
--layer-shadow: 0px 8px 12px 6px rgba(0, 0, 0, 0.15), 0px 4px 4px rgba(0, 0, 0, 0.3);
}

.wlayer:is(.shadow, .tint-shadow) {
.wlayer:is(.shadow) {
box-shadow: var(--layer-shadow, none);
}

.wlayer.shadow .wlayer-inner {
position: absolute;
inset: 0;
background: white;
opacity: calc(calc(var(--color-overlay, 0%) * 1.8) - 5%);
}


.wlayer:is(.tint-shadow, .tint) .wlayer-inner {
position: absolute;
inset: 0;
background: hsl(var(--webgen-primary-hue), var(--webgen-primary-sat), 40%);
opacity: calc(calc(var(--color-overlay, 0%) * 1.8) - 5%);
}

[data-theme="light"] .wlayer {
color: black;
}

[data-theme="dark"] .wlayer {
--layer-shadow: none;
}

[data-theme="dark"] .wlayer:is(.tint-shadow, .tint) .wlayer-inner {
background: hsl(var(--webgen-primary-hue), var(--webgen-primary-sat), 80%);
}
16 changes: 4 additions & 12 deletions src/components/Layer.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
import { Component } from "../Component.ts";
import { createElement } from "../Components.ts";
import { Custom } from "./Custom.ts";
import './Layer.css';

export type LayerLevels = 0 | 1 | 2 | 3 | 4 | 5;
export type LayerSurface = "tint" | "shadow" | "tint-shadow";

class LayerComponent extends Component {
level = 0;
tintlayer = createElement("div");

constructor(child: Component, level: LayerLevels = 0, surface: LayerSurface = "shadow") {
constructor(child: Component, level: LayerLevels = 0) {
super();
this.wrapper.append(this.tintlayer, child.draw());
this.wrapper.classList.add("wlayer", "wlayer" + level, surface);
this.wrapper.append(child.draw());
this.wrapper.classList.add("wlayer", "wlayer" + level);
this.tintlayer.classList.add("wlayer-inner");
}

setBorderRadius(value: "none" | "tiny" | "mid" | "large" | "complete"): this {
super.setBorderRadius(value);
Custom(this.tintlayer).setBorderRadius(value);
return this;
}
}

export const Layer = (child: Component, level: LayerLevels = 0, surface: LayerSurface = "shadow") => new LayerComponent(child, level, surface);
export const Layer = (child: Component, level: LayerLevels = 0) => new LayerComponent(child, level);

0 comments on commit a4db09b

Please sign in to comment.