Commit Graph
31 Commits
Author SHA1 Message Date
Oleg Isonenandzehjotkah 1f4c53419d feat: Pseudo elements (#5572)
This PR replaces the limited "States" dropdown in the Style Panel with a
flexible input field that supports any CSS selector, pseudo-class, or
pseudo-element. This allows for advanced styling capabilities such as
`:has()`, `:focus-visible`, and complex combinators.

## Key Changes

### Flexible Selector Input
- Replaced the fixed "States" category list with a free-form input
field.
- Supports **any** valid CSS selector (e.g., `:hover`, `::before`,
`:has(:checked)`).
- Validation logic ensures only valid selectors are accepted (triggered
on `Enter` key).

## How to Test
1. Select an element and open the Style Panel.
2. Click on the Local style source or a Token.
3. In the input field (bottom of menu), type a selector like `:hover` or
`:first-child` and press Enter.
4. Verify the selector is added and selected.

---------

Co-authored-by: zehjotkah <111518041+zehjotkah@users.noreply.github.com>
2026-01-19 17:28:47 +01:00
Bogdan Chadkin 02ca084a0c refactor: upgrade to csstree v3 (#5455)
The new version is aware of modern colors and other new css features.
2025-11-23 14:32:12 +03:00
Bogdan Chadkin ccba8d9581 feat: substitute variables in calc and box-shadow (#5049)
Ref https://github.com/webstudio-is/webstudio/issues/4939

Here improved style engine logic to substitute variables in unparsed
values which is essential in cases like box-shadow or calc with
variables.

<img width="334" alt="Screenshot 2025-03-26 at 02 03 03"
src="https://github.com/user-attachments/assets/7b002061-1e83-48d9-abad-70547d1cdfc0"
/>
<img width="554" alt="Screenshot 2025-03-26 at 01 59 40"
src="https://github.com/user-attachments/assets/85597b72-cc74-4be9-9c32-ddc1b6510131"
/>
2025-03-26 18:11:55 +07:00
Bogdan Chadkin 11bb528ed6 feat: support css variables in shadow properties (#5032)
Closes https://github.com/webstudio-is/webstudio/issues/4939

Added css variables support with autocomplete in text-shadow and
box-shadow properties.

Extended our ast with new "shadow" value to properly represent variables
in shadow properties. Though parser still cannot extract variables from
value with variables and falls back to "unparsed" value.

<img width="542" alt="Screenshot 2025-03-23 at 00 45 03"
src="https://github.com/user-attachments/assets/2493d925-3199-4257-b9e8-dc69daa27324"
/>
2025-03-25 23:10:03 +07:00
Oleg Isonen 62b0418476 experimental: Use css editor in keyframes (#4952)
## Description

1. What is this PR about (link the issue and add a short description)

## Steps for reproduction

1. click button
2. expect xyz

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
0000)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env` file
2025-03-13 15:20:14 +01:00
Bogdan Chadkin fcb4e25a9e feat: show unresolved inherited values in style panel (#4990)
Per user request we will not show computed value when inherited from
ancestor.
Chrome devtools seem to show unresolved values in "inherited" section.

<img width="252" alt="image"
src="https://github.com/user-attachments/assets/b7f22ec5-e2ea-47aa-9bad-80622d0aa5f9"
/>
2025-03-13 00:20:46 +07:00
Bogdan Chadkin 051c1ba226 refactor: hyphenate style engine (#4977)
Migrated style object model to hyphenated css properties. A lot of
conversions no longer necessary.
2025-03-11 01:01:37 +07:00
Bogdan Chadkin 3c8ac56c39 refactor: migrate properties data to hyphen case (#4970)
properties data are now more type safe and can accept any CssProperty
name though in case of custom properties (--string) will return
undefined.

This also removes a lot of `keyof typeof properties` castings.
2025-03-08 20:26:40 +07:00
Bogdan Chadkin 6a453b94dc refactor: migrate border and outline to hyphenated properties (#4960)
Migrated two more sections and made ComputedStyleDecl['property'] more
strict instead of just a string, now can get rid from `as StyleProperty`
casting all over the codebase.
2025-03-07 17:16:16 +07:00
Bogdan Chadkin 0889342c33 refactor: switch to hyphenated preset styles (#4930)
Replaced camel case with kebab in all presets
2025-03-04 17:26:32 +07:00
Bogdan Chadkin ebced4532a experimental: improve css variables parsing (#4273)
Ref https://github.com/webstudio-is/webstudio/issues/3399

Here added support for parsing var() when paste styles and fixed cyclic
dependency when use the same var() a few times like `background-image:
var(--gradient), var(--gradient)`.
2024-10-13 15:28:38 +03:00
Bogdan Chadkin 666b7e3efb refactor: support css vars in repeated values (#4255)
Ref https://github.com/webstudio-is/webstudio/issues/3399

Here added support for computing css variables inside layers and tuples
to support cases like

```css
transition-timing-function: var(--ease), var(--ease-in);
```
2024-10-09 16:19:55 +03:00
Bogdan Chadkin bbf37d3e61 refactor: simplify var value fallbacks (#4201)
Ref https://github.com/webstudio-is/webstudio/issues/3399

Initially css variable fallback was defined in schema as array though
it's actually a single value by spec and may contain commas. We don't
have css variables in data yet so should be safe to change schema before
too late.
2024-10-02 18:05:05 +03:00
Bogdan Chadkin d48149fd60 fix: handle invalid or unknown properties (#4151)
Fixes the issue with non existent "before" and "after"
https://discord.com/channels/955905230107738152/1286696101076009031/1286696101076009031
2024-09-23 17:15:31 +02:00
Bogdan Chadkin bb1a5d52eb refactor: improve color picker (#4029)
Color control can be a thin wrapper around color picker

- fixed "inherit" keyword support
- moved intermediate value into color picker
- merge highlight and change low level events
2024-08-30 16:48:28 +02:00
Bogdan Chadkin c1b76b5083 experimental: generate property tooltip from style object model (#4012)
Ref https://github.com/webstudio-is/webstudio/issues/1536
https://github.com/webstudio-is/webstudio/issues/3399

Here added more information about property value source like breakpoint,
instance, style source and state to style object model.

Now this info can be used in property label (simpler version of property
name).

Migrated color, font weight and font family properties to new labels.

<img width="350" alt="Screenshot 2024-08-26 at 17 41 23"
src="https://github.com/user-attachments/assets/0d643647-7472-44cf-96f7-c7da2307d067">
2024-08-26 20:16:17 +02:00
Bogdan Chadkin 9ec235e993 experimental: provide style value source in computed style (#4009)
Ref https://github.com/webstudio-is/webstudio/issues/1536
https://github.com/webstudio-is/webstudio/issues/3399

Here added "source" property to computed style decl. It represents a
color of property labels.
Improved selected state and style source logic.
2024-08-26 12:03:46 +02:00
Bogdan Chadkin 39637c60d9 refactor: switch to style object model in color control (#3993)
Ref https://github.com/webstudio-is/webstudio/issues/1536
https://github.com/webstudio-is/webstudio/issues/3399

Here switched to computed style declarations in color control. Used only
to get value (used value) and currentcolor (computed value).
2024-08-22 20:41:39 +02:00
Bogdan Chadkin 03aa922425 experimental: support selecting style source and state (#3972)
Ref https://github.com/webstudio-is/webstudio/issues/3399
https://github.com/webstudio-is/webstudio/issues/1536

Here added support for selecting specific style source and state when
computing styles. Matching states are now treated as less specific.
2024-08-20 13:55:36 +02:00
Bogdan Chadkin b5585f850d refactor: drop sorting by specificity (#3959)
Ref https://github.com/webstudio-is/webstudio/issues/3399
https://github.com/webstudio-is/webstudio/issues/1536

Even less work needed now to compute style.

Turns out since we check each possible style declaration the order of
keys is determenistic and already can provide the right order.

Here removed computing specificity and ordering by it. Instead
rearranged style declarations lookup.
2024-08-18 15:27:03 +02:00
Bogdan Chadkin 19fd22d6e0 refactor: setup reusable style object model (#3948)
Ref https://github.com/webstudio-is/webstudio/issues/1536
https://github.com/webstudio-is/webstudio/issues/3399

Here added very basic setup for style object model. Computed all
normalized data with "computed" store.

It will let us to integrate style object model
into a few controls and test new engine.

Instance selector now is an input for getComputedStyleDecl to allow
looking into parent styles, like we do for flex child.
2024-08-16 22:09:55 +02:00
Bogdan Chadkin 3dd8c2f482 refactor: upgrade html-tags (#3946)
The new version exports types with normal casing,
the package is completely esm and reexports json with new syntax.

https://github.com/sindresorhus/html-tags/blob/main/index.js#L1

Also reused voidHtmlTags in collapsed instance logic.
2024-08-16 11:24:57 +02:00
Bogdan Chadkin ad1401a87f refactor: store indexed data in style object model (#3943)
Here reduced the work in every cascade value computation by storing all
data in normalized way.

These normalized maps can be created incrementally later.
2024-08-15 21:08:38 +02:00
Bogdan Chadkin c7e88531d7 refactor: optimize html styles access (#3939)
Ref https://github.com/webstudio-is/webstudio/issues/1536

Styles are accessed for specific fields and never iterated. Here output
html styles as single map with composite key tag:property.
2024-08-15 18:26:26 +02:00
Bogdan Chadkin 101fb0d8f8 experimental: optionally support parsing custom properties (#3722)
Ref https://github.com/webstudio-is/webstudio/issues/3399
https://github.com/webstudio-is/webstudio/issues/1536

Here added optional support for custom properties in css parser. Also
refactored basic style object model tests with css/jsx fixtures.
2024-07-15 10:57:46 +02:00
Bogdan Chadkin dc1ccd8e2e experimental: support browser and preset styles in style object model (#3067)
Ref https://github.com/webstudio-is/webstudio/issues/1536

Here added new "layer" option to specificity
which isolate browser and preset styles into own layeys similar to
cascade layers feature from css.
2024-03-29 20:36:20 +07:00
Bogdan Chadkin 9296cd6c1a experimental: support breakpoints and states in style object model (#3055)
Ref https://github.com/webstudio-is/webstudio/issues/1536

Here improved sorting declared values and computing cascade value. Added
support for breakpoints and states. Introduced specificity rules to sort
by State-Breakpoint-StyleSource without complicated logic.
2024-03-28 13:03:56 +07:00
Bogdan Chadkin beb3438224 experimental: support custom properties (#3047)
Ref https://github.com/webstudio-is/webstudio/issues/1536

Here added support for css custom properties in style object model.
Added guaranteed-invalid value to schema to represent initial value of
custom properties.
2024-03-25 19:44:32 +07:00
Bogdan Chadkin dc68851a5b experimental: improve color: currentcolor behavior (#3045)
Here slightly changed how color: currentcolor is treated. Before on
color property inherited value was used. Though this didn't handle the
case when inherited value is also currentcolor. Here found note in
another spec which says color: currentcolor should be interpreted same
as inherit keyword.
2024-03-23 17:00:34 +07:00
Bogdan Chadkin 16f165a681 experimental: support currentcolor in style object model (#3043)
Ref https://github.com/webstudio-is/webstudio/issues/1536

Here added currentcolor keyword support. It is case insensitive and
resolved as a new "used value", while "computed value" still contains
currentcolor.
2024-03-22 15:52:07 +07:00
Bogdan Chadkin 0fab9af9a5 experimental: setup style object model (#3042)
Ref https://github.com/webstudio-is/webstudio/issues/1536

Here added style object model basic functionality with inheritance and a
few keywords like "initial", "inherit" and "unset".

The algorithm is following css spec and will get more features in next
PRs.
2024-03-22 13:23:53 +07:00