273 Commits
Author SHA1 Message Date
Ivan Starkov 13afe43cc5 Update ussets and project (#985)
## 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:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio-designer/blob/main/apps/designer/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `designer/env-check.js` if mandatory
2023-02-10 13:39:35 +03:00
Ivan Starkov 2012428327 Update ver 0.26.0 (#984)
## 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:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio-designer/blob/main/apps/designer/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `designer/env-check.js` if mandatory
2023-02-10 14:12:21 +04:00
Ivan Starkov 58ae2f49b2 Update npm packages (#982)
## Description

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

Update npm packages

## 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:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio-designer/blob/main/apps/designer/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `designer/env-check.js` if mandatory
2023-02-10 12:21:59 +03:00
Bogdan Chadkin 136a7bd157 Represent props on client as map (#972)
Ref https://github.com/webstudio-is/webstudio-designer/issues/696

While normalized array of props give us flexibility with atomic updates
we still cannot use it for collaboration because patches are applied
with index in this array which may leads to unexpected results when two
users collaboate on the same tree, for example both put new prop and
edit it before synchronization by the same index, we are getting
conflict.

To avoid such issues we can switch client representation to maps. Almost
all data have ids to use in map as keys. Map makes collaboration almost
conflict free.
2023-02-08 20:23:41 +03:00
Ivan Starkov cc447fbc63 Update packages (#934)
## Description

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

I want to update saas based on #928

## 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:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio-designer/blob/main/apps/designer/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `designer/env-check.js` if mandatory
2023-02-03 11:41:41 +03:00
Bogdan Chadkin 073062a4bf Move breakpoints to Build table (#926)
Ref https://github.com/webstudio-is/webstudio-designer/issues/744

We are trying to co-locate data and simplify cloning/copying. Here I
migrated Breakpoints.values into Build.breakpoints.

This makes Build responsible to all data scoped to project build similar
to tree scope.

We get projectId defined for free and no need additional sql
maintenance.
2023-02-02 21:43:03 +03:00
Ivan Starkov b05a36defe Update versions (#920)
## 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:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio-designer/blob/main/apps/designer/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `designer/env-check.js` if mandatory
2023-02-02 13:02:49 +04:00
Ivan Starkov 26e8343851 Update remix (#903)
## Description

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

Seems like this killed my dev expierence

https://github.com/remix-run/remix/issues/3123

Fixed in 1.12 gonna try, as otherwise I have 100% cpu load, and need to
stop `pnpm dev` before any changes

## 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:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio-designer/blob/main/apps/designer/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `designer/env-check.js` if mandatory
2023-01-31 12:13:37 +04:00
Ivan Starkov df580ce304 Update remix (#892)
## Description

```bash
pnpm up -r -L '@remix-run/*' 
pnpm up -r -L 'react-router-dom'
```

`react-router-dom` removed.


## 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:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio-designer/blob/main/apps/designer/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `designer/env-check.js` if mandatory
2023-01-30 08:23:08 +03:00
Bogdan Chadkin 6c9ae8594f Upgrade @types/node (#891)
The latest version supports types for websubtle so no need for our types
shim.
2023-01-29 18:05:13 +03:00
Oleg Isonen e925d26bc9 Delete design tokens prototype (#873)
## Description

1. With all the new ideas and directions we don't need that initial
implementation

## Code Review

- [ ] hi @TrySound , 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:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio-designer/blob/main/apps/designer/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `designer/env-check.js` if mandatory
2023-01-28 18:05:53 +01:00
Bogdan Chadkin 8635dc6755 Switch to normalized props on server (#883)
Ref https://github.com/webstudio-is/webstudio-designer/issues/696

Now all props is migrated on client side, we can drop legacy store and
switch to new format server side.
2023-01-28 15:24:23 +03:00
Bogdan Chadkin ff049a000c Inject props store to sdk (#871)
Ref https://github.com/webstudio-is/webstudio-designer/issues/696

We use store to render props in sdk components. Though it's easier to
maintain actual store in designer and provide necessary data to sdk.

Here I added utilities to inject computed store on module level. Now we
can get rid of legacy store and rewrite rest api to use normalized
props.
2023-01-28 10:48:13 +03:00
Bogdan Chadkin bf50c0c547 Move project build schema into separate package (#864)
The new package will be responsible for schema and db access to all
build and tree data.

Decoupling will let us make sdk and project thinner.
2023-01-26 21:03:17 +03:00
Bogdan Chadkin 185fb27c85 Treat component name as generic string (#861)
We want to decouple schema stored in db from sdk which generates a list
of components. Components will be added dynamically later so better
avoid component name enum.
2023-01-26 17:33:26 +03:00
Bogdan Chadkin aba909ad63 Drop preset styles from db (#848)
After discussing with @kof figured we do not need to store preset styles
in db as after sdk upgrade components may still break.

Sdk versioning along with its hardcoded values will solve the problem
better.
2023-01-25 18:55:11 +03:00
Bogdan Chadkin 78196958cd Transform styles without zod (#822)
Found zod allows to pass anything in transform without type checking.
This means we can easily get unexpected result. In this case we could
get undefined as asset.

As a solution I defined two versions of types, client side and stored in
db. Conversion is implemented on db routes side.

This makes data flow more clear and let us describe only two versions of
types instead of tree (in, out, client side).
2023-01-23 20:39:48 +03:00
Bogdan Chadkin bb288f309b Replace UserProp with PropsItem (#833)
Here is migration to new props type with more safe conversion to db
format. Added two versions StoredPropsItem for and PropsItem for client
and got rid of "as" casting.
2023-01-22 15:57:37 +03:00
Bogdan Chadkin 78af54b017 Migrate InstanceProps into Tree table as props column (#819)
InstanceProps is designed to store props per each instance which
requires a lot of sql updates on every props change.

Here moved per instance props into array with props for whole tree. This
way patches are safer to apply on large trees.

```
type PropsItem = {
  id: string,
  instanceId: string,
  name: string,
  required?: boolean,
  type: 'number' | 'string' | 'boolean' | 'asset',
  value: number | string | boolean
}
```
2023-01-20 13:02:13 +03:00
Bogdan Chadkin 6ca1f7088a Bump packages (#814)
Let's release
2023-01-19 13:08:32 +03:00
Bogdan Chadkin 6f5a0bcfbc Bump packages (#805)
Let's release
2023-01-18 14:06:44 +03:00
Bogdan Chadkin 1d457b5b98 Normalize instances in db (#788)
Ref https://github.com/webstudio-is/webstudio-designer/issues/696

Here only migration and converters between tree and list on db access.
2023-01-16 14:58:49 +03:00
Bogdan Chadkin 35354522d9 Move props updates to designer (#784)
Props have a lot of logic to synchronize values. And after moving
updates into designer we get fresh state instantly and can simplify the
logic even more.
2023-01-14 14:11:26 +03:00
Bogdan Chadkin f9052681a3 Simplify props state (#783)
Turns out we store whole db representation in each props each per
instance item. This is wasteful and increase complexity of code.

```
{
  [InstanceId]: {
    id: UUID,
    instanceId: InstanceId,
    treeId: TreeId,
    props: UserProp[]
  }
}
```

Where instance id is duplicated and tree id is provided as patch
context. Id can be replaced with combination of instance id and tree id.

```
{
  [InstanceId]:  UserProp[]
}
```
2023-01-14 12:46:49 +03:00
Bogdan Chadkin 3abb54a875 Migrate to nanostores (#779)
Ref https://github.com/nanostores/nanostores

Nanostores is another open source implementation of reactive states.
Supports a lot of frameworks and provides useful utilities like computed
stores. Api is slightly different

```
store.get(): Value
store.set(value: Value)
```

`useStore` resolves only value so I temporary added custom `useValue` to
not rewrite whole project. Since we gonna use computed atoms it makes
more sense to invoke useStore where atom value is used instead of
reusable hook.
2023-01-13 15:13:40 +03:00
Bogdan Chadkin 44a7083fde Drop css rules from instance (#775)
Ref https://github.com/webstudio-is/webstudio-designer/issues/696

Finally got rid of legacy instance.cssRules.
Removed style utils for working with tree.
Now will be easier to normalize tree.
2023-01-13 13:04:21 +03:00
Bogdan Chadkin 8a691b92d1 Update normalized styles directly (#757)
Ref https://github.com/webstudio-is/webstudio-designer/issues/696

Migrated updating and rendering to normalized styles. There are still a
few cases to migrate so left legacy root instance updates.

Styles are updated with immerhin consistently with whole project.

Can be tested changing styles and deleting breakpoints.
2023-01-09 12:17:20 +03:00
Bogdan Chadkin 7d90c3f56c Bump packages (#753)
Gonna be big release.
2023-01-06 17:31:39 +03:00
Bogdan Chadkin 6387accf0d Render static css from normalized styles (#750)
Ref https://github.com/webstudio-is/webstudio-designer/issues/696

Gradually starting to migrate to new styles format. Here replaced
getCssRules and getPresetStylesMap with getStyleRules and
getPresetStyleRules utilities.

Will reuse both at once on release.
2023-01-06 16:44:03 +03:00
Bogdan Chadkin 7c5c737bfb Normalize styles in database (#749)
Ref https://github.com/webstudio-is/webstudio-designer/issues/696

Here only migration and transforms for load and patch. Styles have the
following type and stored in Tree.styles column.

```
Array<{
  breakpointId: string,
  instanceId: string,
  property: StyleProperty,
  value: StyleValue
}>
```

Did migration with cursor pagination with 1000 trees per transaction.
2023-01-06 14:38:21 +03:00
Bogdan Chadkin f2a851cb5b Bump remix to 1.9.0 (#740)
- https://github.com/remix-run/remix/releases/tag/remix%401.8.0
- https://github.com/remix-run/remix/releases/tag/remix%401.9.0

Build issue still not fixed
(https://github.com/webstudio-is/webstudio-designer/pull/725)
2023-01-05 21:27:55 +03:00
Bogdan Chadkin d79c96566b Store preset style separately from tree (#724)
Before we populated preset style on instance creation. This does not let
us to distinct preset style from local one.

As an option we could use preset style hardcoded in meta though this may
affect user when we change defaults.

Here I added presetStyle column in Tree table with the list of styles
for component.

```
Array<{
  component: string,
  property: string,
  value: StyleValue
}>
```

Will style controls as grey for such styles.
2023-01-05 21:27:33 +03:00
Roman Pominov 91e209e974 rename Spacing to Space (#745)
Renamed Spacing section to Space in code and in UI
2023-01-05 14:59:32 +03:00
Bogdan Chadkin 5fe9364cb1 Improve units in style panel (#735)
Ref https://github.com/webstudio-is/webstudio-designer/issues/366

- generate grouped units for non length values
- show unit select when initial unitless

So we get all 3 points from the issue

- all properties has only supported units
- hidden but supported units still can be entered
- unsupported values are validated

<img width="243" alt="Screenshot 2023-01-04 at 14 12 29"
src="https://user-images.githubusercontent.com/5635476/210546684-ca696096-f78c-445f-bbc3-04db7326239b.png">
<img width="224" alt="Screenshot 2023-01-04 at 14 14 54"
src="https://user-images.githubusercontent.com/5635476/210546689-396c7d42-e6f0-42a9-869c-7b231baa3d71.png">
2023-01-04 18:20:15 +03:00
Mateusz Burzyński 28a2d85465 Tweak Instance type (#732) 2023-01-03 21:27:25 +01:00
Bogdan Chadkin 5a2b3b8eec Parse properties initial value (#726)
Ref https://github.com/webstudio-is/webstudio-designer/issues/366

Parsed initial values to get correct unit instead of px for some
properties. There is still edge case with unitless values I'm gonna fix
in another PR.

Also bumped mdn-data and removed overrides fixed on mdn side.
2023-01-03 19:57:16 +03:00
Bogdan Chadkin 9c71929b25 Upgrade to remix 1.7.6 (#725)
https://github.com/remix-run/remix/releases/tag/remix%401.7.0
https://github.com/remix-run/remix/releases/tag/remix%401.7.4

du -ckd1 node_modules
-795648
+798524

Not much changes though I found since
[1.7.5](https://github.com/remix-run/remix/releases/tag/remix%401.7.5)
build started to hang when run with turbo or recursive pnpm run.

Looks like in this commit some stream or connection not closed when
build is finished.

https://github.com/remix-run/remix/pull/4410

Let's see if not fixed in newer versions and then file an issue.
2023-01-03 18:24:44 +03:00
Oleg Isonen ce5cfeca0a Add object position property (#708)
## Description

Somehow we forgot to add object-position

## Steps for reproduction

1. select instance
2. go to sizes section in style panel

## Code Review

- [ ] hi @istarkov  I need you to do
  - conceptual review (architecture, feature-correctness)

## 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-designer/blob/main/apps/designer/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `designer/env-check.js` if mandatory
2022-12-27 13:21:45 +01:00
Bogdan Chadkin 7734458552 Bump to remix 1.6.8 (#695)
- https://github.com/remix-run/remix/releases/tag/remix%401.6.8
- https://github.com/remix-run/remix/releases/tag/remix%401.6.7
- https://github.com/remix-run/remix/releases/tag/remix%401.6.6
- https://github.com/remix-run/remix/releases/tag/remix%401.6.5

Gonna upgrade step by step so we could narrow troubling versions.
Here narrowed to single version of remix in designer and packages.

```diff
du -ckd1 node_modules
-813512
+795580
```
2022-12-25 16:28:51 +03:00
Ivan Starkov 3ef9b92126 Bump versions (#693)
## 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:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio-designer/blob/main/apps/designer/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `designer/env-check.js` if mandatory
2022-12-24 20:20:07 +03:00
Bogdan Chadkin 845d53981c Improve packages publish (#676)
- all workspace dependencies are use with `workspace:^` protocol which
on publish is replaced with `^VERSION`. This will let us to upgrade
transitive packages in saas without shaman dancing around package.json
and lockfile.
- publish-to-npm script is replaced with `pnpm -r publish` which
recursively publishes all packages if version does not exist in npm
- dropped yarn lockfile
2022-12-22 17:06:27 +03:00
Bogdan Chadkin b3c87af7c1 Migrate to pnpm for package management (#641)
- setup corepack for pnpm and forbid yarn usage with "engines" field
- converted yarn lockfile into pnpm lockfile with `pnpm import` command
- replaced yarn with pnpm in scripts and github actions, had to use
custom cache to support corepack

This PR is only migration. Will use new pnpm features in other PRs.

```diff
du -ckd1 node_modules (yarn)
- 1125032

du -ckd1 node_modules/.pnpm
+ 857456
```

Install time (including cache downloads) in github actions reduced from
42s to 23s


## Before requesting a review

- [ ] if the PR is WIP - use draft mode
- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")
- [ ] what kind of review is needed?
  - [x] conceptual
  - [X] detailed
  - [ ] with testing

## Test cases

- [ ] step by step interaction description and what is expected to
happen

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio-designer/blob/main/apps/designer/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `designer/env-check.js` if mandatory
2022-12-22 12:16:13 +03:00
Bogdan Chadkin 7019d50b30 Bump packages versions (#672)
Let's release
2022-12-21 17:43:33 +03:00
Bogdan Chadkin 41c533271a Convert text children to nodes in tree (#654)
Ref https://github.com/webstudio-is/webstudio-designer/issues/651

We want to normalize our tree structure and need to distinct text
children with ids. Now instead of string its respresented as
```
{
  type: 'text',
  value: string
}
```

This also gives us a little type safety because typeof child ===
'string' ignores when child cannot be string.
2022-12-19 22:44:13 +03:00
Bogdan Chadkin bb0e315338 Update hovered rect when scroll ends (#650)
Ref https://github.com/webstudio-is/webstudio-designer/issues/630

Simplified hovered logic to single effect, removed unnecessary
nano-state container and fixed hovered outline rect when scroll ends.
2022-12-18 16:44:24 +03:00
Mateusz Burzyński 86292353bc Unify Storybook config (#585)
This PR moves most of the Storybook configs into a single, private,
package that can be imported/required by your packages. It aims to keep
the config the same for all of them as much as possible - so, for
example, all of the packages are now using Webpack 5 in their
Storybooks.
2022-12-17 21:50:59 +01:00
Bogdan Chadkin ff7c1c923e Install missing deps with types (#647)
In https://github.com/webstudio-is/webstudio-designer/pull/646 I checked
with build. Now found more issues with typescript.

Also forgot to migrate to jest/globals "project" package.
2022-12-17 11:41:34 +03:00
Oleg Isonen 703a9fe215 Merge pull request #639 from webstudio-is/621-smallest-breakpoint-should-start-from-0
Start the smallest breakpoint at 0
2022-12-16 18:35:38 +00:00
Bogdan Chadkin 752768abbc Use explicit imports from @jest/globals (#645)
pnpm prevents access to jest and @types/jest from packages so we need to
explicitly install it. Though @types/jest is not officially maintained
and often late for months with new major which bloats node_modules with
two versions of jest transitives.

Here is alternative way to use official types. The only downside is
complains these types has less descriptions.
2022-12-16 16:35:22 +03:00
Oleg Isonen b79df63f33 Merge branch 'main' into 621-smallest-breakpoint-should-start-from-0 2022-12-16 13:33:25 +00:00