Commit Graph
227 Commits
Author SHA1 Message Date
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
Bogdan Chadkin d05b1bc21f Resolve tsconfig package (#643)
While migrating to pnpm I got an issue with our extends relying on
node_modules. pnpm have only symlinks and do not have hoisted
node_modules in the root.

Here I switched extends to package name as all tools can resolve it and
tweaked remix tsconfig to extend from packages folder instead of
node_modules.
2022-12-16 13:09:33 +03:00
Oleg Isonen 7f62539435 start the smallest breakpoint at 0 and use the upper bound to set the canvas size 2022-12-15 18:09:04 +00:00
Bogdan Chadkin 122bd8adb5 Track selected rect close to element (#627)
Ref https://github.com/webstudio-is/webstudio-designer/issues/598

When tracking selected element from the root it's hard to get current
element which can be changed with props.

One more issue is storing element in state doubles amount of renders and
in selected instance logic we have a chain of state -> effect -> state
-> effect cases.

Here I store element in ref so we avoid rerender when set element to
state. Then tracked element rect is not written to state and sent to
designer directly.

Since the effect is unmounted along with element we do not need to use
mutation observer to track parent changes and can just recompute rect on
remount.
2022-12-15 16:01:40 +03:00
Bogdan Chadkin 1459fd7cbd Remove treeId from props updates (#635)
Will help with
https://github.com/webstudio-is/webstudio-designer/issues/628

treeId is stored in every props update which complicates data flow and
requires passing it everywhere. Here I instead pass it inside of
transaction.

This allowed us pass undefined in props data when select instance so we
no longer need to create empty instance props. Updates will create it
lazily.
2022-12-15 15:56:27 +03:00
Oleg Isonen 142fbda626 defaultStyle presetStyle 2022-12-14 23:51:01 +00:00
Ivan Starkov af90b31945 Bump versions (#616)
## 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?
  - [ ] conceptual
  - [ ] 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-12 23:56:10 +03:00
Mateusz Burzyński 35af8358e9 Move @webstudio-is/design-tokens to @webstudio-is/react-sdk prod deps (#602)
This should fix the problem reported on this line:
https://github.com/webstudio-is/webstudio-saas/actions/runs/3657427162/jobs/6181006430#step:6:52
, cc @andrasbacsai

Even though [you only reach for a
type](https://github.com/webstudio-is/webstudio-designer/blob/1a66acb79c8c560b3a54b55512c2779991a68eff/packages/react-sdk/src/tree/root.ts#L11),
you still should declare this package among your dependencies -
otherwise, it won't be installed by your consumers and thus the TS
compilation will fail for them.
2022-12-12 15:44:32 +01:00
Ivan Starkov 12a3da3140 Bump versions 2022-12-12 14:17:23 +03:00
Ivan Starkov 1ac167d959 Add initial props 2022-12-12 00:14:43 +03:00
Ivan Starkov 6cc2847cf6 Bump versions (#582)
For easier version change next time, now all has same version.
2022-12-09 21:52:10 +04:00
Andras Bacsai a995647084 fix:eslint, bump versions 2022-12-09 09:26:52 +01:00
Andras Bacsai 27469787a0 fix eslint 2022-12-08 13:21:37 +01:00
Ivan Starkov cb7f22f7a4 Bump packages versions (#566)
## 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?
  - [ ] conceptual
  - [ ] 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-07 22:31:38 +04:00
Ivan Starkov bb6a1d28e3 [progress] Naive aspectRatio (#556)
## 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?
  - [ ] conceptual
  - [ ] 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-07 22:05:49 +04:00
Bogdan Chadkin 05e69ac016 Give body separate type in sdk (#560)
Body is the only container which should not be listed. After discussing
with Oleg decided to give it separate body type.
2022-12-07 16:17:33 +03:00
Oleg Isonen 3c088b2c04 Merge branch 'main' into 494-primitive-tokens 2022-12-03 15:38:31 +01:00
Bogdan Chadkin fb946ab296 Fix span component type (#552)
Mistyped when added type to components.
2022-12-03 16:33:06 +03:00
Oleg Isonen 8d26bf781b move shared design tokens logic to a separate package 2022-12-03 12:09:22 +00:00
Oleg Isonen 0d07f9a27c Merge branch 'main' into 494-primitive-tokens 2022-12-03 11:41:08 +00:00
Ivan Starkov b6c6f57f2c Fix that images with asset had value inside db (#549)
ref #196

- [x] UserProps now [discriminated union by
type](https://github.com/webstudio-is/webstudio-designer/blob/img_asset/packages/react-sdk/src/user-props/schema.ts#L10-L31)

- [x] Data migrations done
2022-12-02 14:53:30 +04:00
Oleg Isonen a06a3db058 Merge branch 'main' into 494-primitive-tokens 2022-12-02 00:27:51 +00:00
Roman Pominov 55280b8348 use RemixLink in Link (#488)
Fixes #457
2022-11-29 13:42:40 +03:00
Bogdan Chadkin 6b761bb000 Replace tsc with esbuild to build packages (#543)
Build of whole monorepo without cache takes 1min or more on my laptop.
tsc is very slow tool for this. Also having rootDir in tsconfig prevents
checking outside of src folder.

Here I added "scripts" package with "build-package" bin. It does both
esm and cjs builds. --watch flag support completely replaces tsup for
us.

Now full rebuild of monorepo without cache takes only 10s including
prisma-client, http-client and designer builds.
2022-11-29 10:04:25 +03:00
Bogdan Chadkin 3e96357a2c Use sources as type deifnitions (#539)
Right now our build and CI take a lot of time. 1:40min - 2min on CI and
1min locally. We spend time on vercel, on main CI, on publish and
locally.

At the moment in packages anything outside of src folder is not checked
because of rootDir.

We have to generate "references" field on precommit.

All these issues can be avoided if remove .d.ts generation completely
and specify sources in "types" field. This way we get zero build time
for types and can switch to other build tool (like esbuild) for .js
generation and get almost instant build on vercel, on main CI and on
publish.

Downsides

- it can be slower (actually not really caz we delete .tsbuildinfo cache
anyway and we can still generate it with incremental flag)
- it contraditcs recommended practices for published packages (we can
generate .d.ts in publish script only and use "types" as source
internally)
2022-11-28 22:27:56 +03:00
Ivan Starkov fe3811a373 Move defaults into ws (#541)
meta props are moved to *.ws.ts
Component removed from *.ws.ts

This allows to merge ws props with registered components props
`registerComponents` now are 
-   registerComponents(customComponents);
-   registerComponentsMeta(customComponentsMeta);

_(Splitting will allow for code splitting to work.)_

Removal of `Component` (and then `Icon` prop) would allow serializing
*.ws.ts metadata between iframe and app designer

Next PR:

Move Icon into base64 or like.

publish/subscribe ws meta of registered components, so it can be reused
on the Designer side
I need this to pass props of registered components to Designer.
2022-11-28 21:14:35 +04:00
Bogdan Chadkin b4bf640dcc Replace flags with component type (#532)
Boolean flags may have a lot of combinations which can lead to
unexpected bugs. Better approach is to categorize nodes with specific
behaviours.

Here I added 5 types

- container - can accept other components with dnd
- control - usually form controls like inputs, without children
- embed - images, videos or other embeddable components, without
children
- rich-text - can be edited on double click
- rich-text-child - formatted text fragment, not listed in components
list
2022-11-28 15:04:53 +03:00
Roman Pominov 26f0990347 fix UserProp schema 2022-11-28 12:53:56 +04:00
Roman Pominov da1e8d5056 fix rebase 2022-11-28 11:44:15 +04:00
Oleg Isonen 4fcbf1d108 Merge branch 'main' into 494-primitive-tokens 2022-11-27 18:41:41 +01:00
Ivan Starkov a7125fe695 [release-fix] Fix adding new prop (#531)
- [x] - New property creation was broken
- [x] - Switch on `tag` was seriosly broken

<img width="403" alt="image"
src="https://user-images.githubusercontent.com/5077042/204138926-2ca2e13c-6e46-4ca1-9233-ffdc6475dad8.png">
2022-11-27 21:32:03 +04:00
Bogdan Chadkin 6e5c0f9c1d Split Link and RichTextLink components (#530)
Droppable link an link created in text editor have different
requirements. We should split them. In the next PR they will get
different types so we will avoid similar issues in the future.
2022-11-27 17:25:24 +03:00
Oleg Isonen 52a4f9af6b added aspect ratio property to sizes 2022-11-27 13:46:53 +01:00
Bogdan Chadkin a8f1f407b7 Bump saas packages (#527)
Added publish script to image package and bumped everything changed
since latest bump by checking `git log -1 -- .`
2022-11-27 13:48:26 +03:00
Ivan Starkov 9e3f3c46c6 Fix accidentally commented code at #516 (#524)
https://github.com/webstudio-is/webstudio-designer/pull/516#pullrequestreview-1194934498
2022-11-27 11:44:48 +04:00
Roman Pominovandistarkov a9fede0a1d Ability to replace SDK components (#516)
Whats done:
- [x] - Added getComponent, getComponentMeta (old getComponenMeta
renamed to getComponentMetaProps)
- [x] - Added `registerComponents` (for now able only override existing
components)
- [x] - Renamed react-sd `remix` folder to `app`
- [x] - At the `app` folder added `custom-components/Image` wrapper
component, which reads assets etc, and use `webstudio/image`
- [x] `getParams`, `setParams` added at `react-sdk/app/` as they are app
level


TODO:
- [x] Create "normal" `useParams` to be able to use data.params
https://github.com/webstudio-is/webstudio-designer/blob/c05f40818beaac8a811fe0a97ba49e30f01f5045/packages/react-sdk/src/app/custom-components/image.tsx#L15-L23
- [x] Reuse props meta from imported image - created issue
https://github.com/webstudio-is/webstudio-designer/issues/521

Co-authored-by: istarkov <istarkov@gmail.com>
2022-11-27 02:47:14 +04:00
Oleg Isonen 8f64061c27 load tokens 2022-11-26 18:37:51 +01:00
Oleg Isonen 1b8b692b73 remove todos, lint 2022-11-25 20:45:29 +01:00
Oleg Isonenandistarkov 4c8989784b Primitive tokens (#507)
https://github.com/webstudio-is/webstudio-designer/issues/494

This PR Renders this UI and, when adding tokens - renders CSS variables
on the canvas: It's behind a feature flag.

<img width="411" alt="Screenshot 2022-11-25 at 15 51 00"
src="https://user-images.githubusercontent.com/52824/204009859-81ed72c4-e758-4973-be49-c8c65e6b4661.png">


## 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?
  - [ ] conceptual
  - [ ] 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

Co-authored-by: istarkov <istarkov@gmail.com>
2022-11-25 19:51:54 +01:00
istarkov 466ae357d8 Fix errors 2022-11-25 16:01:32 +00:00
Oleg Isonen 7439926c9b Merge branch 'main' into 494-primitive-tokens 2022-11-25 14:52:56 +01:00
Oleg Isonen 48f66a0dc2 use any temporarily 2022-11-25 14:13:35 +01:00
Ivan Starkov 843467a691 Image (#502)
- [x] - Image optimization component moved into standalone package
- [x] - generate-arg-types moved into standalone package - one issue
with current yarn https://github.com/yarnpkg/yarn/issues/4964 (you need
to delete root node_modules, then yarn and yarn build to make
generate-arg-types to work)
- [x] - move json into `__generated__` folder, (allow import json from
__generated__ folders only)
- [x] - Icons moved all gen into `__generated__`
- [x] - css-data generated content moved to `__generated__`
2022-11-25 12:27:44 +04:00
Bogdan Chadkin 7dbbfeb6b3 Fix sdk 2022-11-24 21:02:19 +03:00
Bogdan Chadkin 18d28b50cb Bump sass deps
We need to bump all sass deps to get esm support
and treeshake bundled code.
2022-11-24 20:59:41 +03:00
Bogdan Chadkin 16984b8bf7 Improve packages auto publish (#508)
Current solution often fails with

> You cannot publish over the previously published versions

Here I added small script which compares committed version and version
on npm and publish if do not match.

All scripts are run by turbo. So publishing new package is just changing
package script now.
2022-11-24 16:00:24 +03:00
Bogdan Chadkin 7f44d78279 Improve text editor styling and enable auto focus (#504)
Ref https://github.com/webstudio-is/webstudio-designer/issues/107

- fixed bold italic styling
- populate default style for instances created from text editor
- added unmount support to css engine
- auto focus text editor when start editing
2022-11-24 00:07:45 +03:00