5 Commits
Author SHA1 Message Date
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 c40f5e507d Replace @types/css-tree override with patch (#1783)
Split from https://github.com/webstudio-is/webstudio-builder/pull/1634

We may need more things from css-tree and reexporting everything is
harder to maintain so here added patch instead of types override.
2023-06-14 17:51:13 +03:00
Ivan Starkov fcee225a5f Add simple background parser (#1240)
## Description

ref #877 - the ability to parse multiple gradient layers from Figma 
![Screen Recording 2023-03-18 at 00 25
12](https://user-images.githubusercontent.com/5077042/226031486-0dc0978b-5572-4dd6-9441-b86b2e469a7a.gif)


closes #1255 - now background added at the top

fixes css value input invalid input now shows as invalid

## Steps for reproduction

Copy some background from figma like
```
background: linear-gradient(180deg, #11181C 0%, rgba(17, 24, 28, 0) 36.09%), none, linear-gradient(180deg, rgba(230, 60, 254, 0.33) 0%, rgba(255, 174, 60, 0) 100%), radial-gradient(54.1% 95.83% at 100% 100%, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%), linear-gradient(122.33deg, rgba(74, 78, 250, 0.2) 0%, rgba(0, 0, 0, 0) 69.38%), radial-gradient(92.26% 201.29% at 98.6% 10.65%, rgba(255, 174, 60, 0.3) 0%, rgba(227, 53, 255, 0) 100%) /* warning: gradient uses a rotation that is not supported by CSS and may not behave as expected */, radial-gradient(84.64% 267.51% at 10.07% 81.45%, rgba(53, 255, 182, 0.2) 0%, rgba(74, 78, 250, 0.2) 100%) /* warning: gradient uses a rotation that is not supported by CSS and may not behave as expected */, #EBFFFC;
```

Open any layer paste it into the code, and click enter or blur.
See layers added. BGColor has changed if set.


## Code Review

- [x] 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

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

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio-builder/blob/main/apps/builder/docs/test-cases.md)
document
- [x] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2023-03-18 21:33:48 +04:00
Ivan Starkov b39e6a6376 Fix switch display (#569)
Switching display from flex on block caused error in input field

We were not able to parse display block etc

As this is not fixed for display props.
```
setProperty should be called with a style object, string is deprecated
```

So we got that "parsed not valid behavior" which we decided to be
invalid.
2022-12-08 12:07:05 +04:00
Ivan Starkov ffae4bd403 Make CSSValueInput controllable, (#551)
CSSValueInput used useEffect and executed onChange etc events on its
own. What in case of any small changes caused loops and strange
behavior. Now should execute everything only as a result of user input.

`parseCssValue` - now stupid parse CSS value and someday will be used
only inside text-control.
setProperty - now accepts StyleValue, the string param is deprecated,
warning set.

CSSValueInput now not update styles during editing.

unit menu now not hiding during formulas etc

fixed bug with updating style on newly created items

fixed scrub bugs with unsubscribing

css-tree Adds 52101 gzip bytes. 
A lot of size is coming from here 

https://github.com/csstree/csstree/blob/97d7f3b95a3efd8f431af39986acc149dceefa59/lib/data.js
more than 1/3 of `esm` size (20+kb gz), and most huge are properties
json we need and use.

Doesn't look tree-shakeable, anyway can be loaded lazily as until
editing we don't need to validate CSS vars.

Investigating: 
- [x] - Changing any style Combobox with mouse cause multiple value
updates to previous and current value (was a blur event issue)
2022-12-07 14:32:34 +04:00