Compare commits
2 commits
e4a640ccee
...
2bd8afd486
Author | SHA1 | Date | |
---|---|---|---|
2bd8afd486 | |||
1f1c6d92b1 |
2 changed files with 23 additions and 10 deletions
|
@ -81,23 +81,35 @@ class SpeciesFacePickerOptions extends HTMLElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MeasuredContent extends HTMLElement {
|
// TODO: If it ever gets wide support, remove this in favor of the CSS rule
|
||||||
|
// `interpolate-size: allow-keywords`, to animate directly from `auto`.
|
||||||
|
// https://drafts.csswg.org/css-values-5/#valdef-interpolate-size-allow-keywords
|
||||||
|
class MeasuredContainer extends HTMLElement {
|
||||||
|
static observedAttributes = ["style"];
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
setTimeout(() => this.#measure(), 0);
|
setTimeout(() => this.#measure(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#measure() {
|
attributeChangedCallback() {
|
||||||
// Find our `<measured-container>` parent, and set our natural width
|
// When `--natural-width` gets morphed away by Turbo, measure it again!
|
||||||
// as `var(--natural-width)` in the context of its CSS styles.
|
if (this.style.getPropertyValue("--natural-width") === "") {
|
||||||
const container = this.closest("measured-container");
|
this.#measure();
|
||||||
if (container == null) {
|
|
||||||
throw new Error(`<measured-content> must be in a <measured-container>`);
|
|
||||||
}
|
}
|
||||||
container.style.setProperty("--natural-width", this.offsetWidth + "px");
|
}
|
||||||
|
|
||||||
|
#measure() {
|
||||||
|
// Find our `<measured-content>` child, and set our natural width as
|
||||||
|
// `var(--natural-width)` in the context of our CSS styles.
|
||||||
|
const content = this.querySelector("measured-content");
|
||||||
|
if (content == null) {
|
||||||
|
throw new Error(`<measured-container> must contain a <measured-content>`);
|
||||||
|
}
|
||||||
|
this.style.setProperty("--natural-width", content.offsetWidth + "px");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define("species-color-picker", SpeciesColorPicker);
|
customElements.define("species-color-picker", SpeciesColorPicker);
|
||||||
customElements.define("species-face-picker", SpeciesFacePicker);
|
customElements.define("species-face-picker", SpeciesFacePicker);
|
||||||
customElements.define("species-face-picker-options", SpeciesFacePickerOptions);
|
customElements.define("species-face-picker-options", SpeciesFacePickerOptions);
|
||||||
customElements.define("measured-content", MeasuredContent);
|
customElements.define("measured-container", MeasuredContainer);
|
||||||
|
|
|
@ -70,9 +70,10 @@
|
||||||
%li<
|
%li<
|
||||||
= zone.label
|
= zone.label
|
||||||
- if item_zone_partial_fit? appearances_in_zone, @all_appearances
|
- if item_zone_partial_fit? appearances_in_zone, @all_appearances
|
||||||
|
= " "
|
||||||
%span.zone-species-info{
|
%span.zone-species-info{
|
||||||
title: item_zone_species_list(appearances_in_zone)
|
title: item_zone_species_list(appearances_in_zone)
|
||||||
}
|
}<
|
||||||
(#{appearances_in_zone.size} species)
|
(#{appearances_in_zone.size} species)
|
||||||
- else
|
- else
|
||||||
%span.no-zones (None)
|
%span.no-zones (None)
|
||||||
|
|
Loading…
Reference in a new issue