0
Fork 0
mirror of https://github.com/penpot/penpot-export.git synced 2025-01-06 14:50:10 -05:00
Commit graph

64 commits

Author SHA1 Message Date
Roberto Redradix
f988d73655 feat(core): sort assets reproducibly by name 2023-09-25 15:07:06 +02:00
Roberto Redradix
5392f8a4e0 build: bump version to 0.1.0-beta.0 2023-09-15 19:14:45 +02:00
Roberto Redradix
122c5b6071 docs: license under Apache License, Version 2.0 2023-09-15 19:14:42 +02:00
Roberto Redradix
7927ed8f98 build(core,cli): build TypeScript before packing 2023-09-15 19:00:55 +02:00
Roberto Redradix
f5d3badde2 chore(demo): update generated files 2023-09-15 18:51:38 +02:00
Roberto Redradix
8a39949ed0 feat!(core): follow W3C draft design tokens format spec for colors and typographies in JSON output
Draft spec (24 July 2023): https://tr.designtokens.org/format/

Deprecate JSON output for page components, since the spec is not flexible enough for arbitrary properties.
2023-09-15 18:51:35 +02:00
Roberto Redradix
ba9886beb4 feat(demo): split demos per output format
Adds a SCSS-specific demo
2023-09-15 18:12:15 +02:00
Roberto Redradix
ec3e1b52e9 chore(demo): update generated files 2023-09-13 13:06:37 +02:00
Roberto Redradix
660f2b9ae9 refactor(core): decouple name scoping logic from API adapters
Introduce the concept of transformer functions. A transformer function will receive an assets as an input and will output the same kind of asset.

Scoping class names in CSS was a transformation applied to typography and page components assets when the output is CSS.

Decoupling this transformation from the rest of the adapter results in cleaner API inbound adapters, without any project-specific logic, so now they can be co-located close to the PenpotClient code.
2023-09-13 11:35:18 +02:00
Roberto Redradix
07977124da chore(demo): update generated files 2023-09-12 18:20:19 +02:00
Roberto Redradix
1681cefb05 refactor(core): add better semantics with wrapper internal types
Additionally, throw runtime internal errors when TypeScript assumptions are not fulfilled.
2023-09-12 18:19:10 +02:00
Roberto Redradix
2b3381fa97 feat!(core): use 8-digit hexadecimal RGBA colors
The 8-digit hexadecimal RGBA syntax is a more standard way to represent colors than the rgba() color function, which is CSS-specific.

The 8-digit hex notation is valid CSS as of the CSS Level 4 spec: https://www.w3.org/TR/css-color-4/#hex-notation

Additionally, the CSS rgba() comma-separated color function is considered *legacy color syntax* as per the CSS Level 4 spec: https://www.w3.org/TR/css-color-4/#legacy-color-syntax

Sass has built-in support for CSS Level 4 color notations: https://sass-lang.com/documentation/values/colors/

The 8-digit hexadecimal RGBA is a drop-in replacement for rgba() values in both CSS and SCSS, so this is functionally compatible if the file is used directly.

BREAKING CHANGE: drops CSS rgba() values in all output formats. It's a soft breaking change for CSS and SCSS outputs, but a hard one for JSON.
2023-09-12 13:28:09 +02:00
Roberto Redradix
f7275f8e30 refactor(core): move all re-export declaration to the end of the files 2023-09-11 18:45:28 +02:00
Roberto Redradix
173472aa36 chore(demo): update generated files 2023-09-11 18:45:28 +02:00
Roberto Redradix
1fcb0e0860 feat(core): describe typography requirements and Google Fonts implementation aid 2023-09-11 18:45:28 +02:00
Roberto Redradix
562e1d77e3 chore(demo): import SCSS files 2023-09-07 18:07:59 +02:00
Roberto Redradix
af856a642e refactor(core): separate file writting logic from output adapters 2023-09-07 17:26:22 +02:00
Roberto Redradix
f33dc7a9b8 feat(core): allow to export SCSS files 2023-09-07 16:59:03 +02:00
Roberto Redradix
c035375084 chore(demo): update assets and HTML 2023-09-07 16:58:39 +02:00
Roberto Redradix
9a39da7a65 refactor(core): delegate CSS tokenization and serialization to the outputter 2023-09-07 16:58:39 +02:00
Roberto Redradix
b76d4d57ef refactor(core): serialize each CSS variable at a time 2023-09-07 10:50:33 +02:00
Roberto Redradix
70c3d9a665 refactor(core): sort config types 2023-09-05 17:56:42 +02:00
Roberto Redradix
abe6e54f4a chore(demo): update with JSON outputs 2023-09-05 14:43:33 +02:00
Roberto Redradix
98597dbf4c feat!(core): allow to export JSON files
BREAKING CHANGE: CSS variables (color) are no longer lowercase. Since CSS custom property names are case sensitive, this would break existing consumers.
2023-09-05 14:40:00 +02:00
Roberto Redradix
1fd8a579de chore(core): remove unused type imports 2023-09-05 12:08:32 +02:00
Roberto Redradix
bef9cd65ef refactor(core): remove PenpotExportFile cumbersome abstraction 2023-09-05 12:03:54 +02:00
Roberto Redradix
924d5bec7b refactor(core): colocate schemas, types and validators 2023-09-04 18:49:12 +02:00
Roberto Redradix
f7b972e032 chore(core): disallow empty arrays in user config 2023-09-04 17:42:36 +02:00
Roberto Redradix
83ba6f93d5 refactor(core): validate user config in a more expressive way
zod unions are exclusive, so the UserConfig type couldn't be kept as a union either for having at least a colors, typographies or pages output.

This check has been moved to a runtime zod refine custom validation.
2023-09-04 17:42:34 +02:00
Roberto Redradix
bf6f6a723a test(core): add tests for CSS ident tokens 2023-09-04 13:41:32 +02:00
Roberto Redradix
e35186eae9 refactor!: split penpot-export into cli and core modules 2023-09-01 17:43:45 +02:00
Roberto Redradix
e13d644805 refactor!(cli): rename pentpot-css-export to penpot-export 2023-09-01 17:43:45 +02:00
Roberto Redradix
ec802a35d0 feat!(cli): output CSS colors with alpha channel 2023-09-01 17:43:45 +02:00
Roberto Redradix
41303b0a51 docs(demo): document environment variables 2023-09-01 17:43:45 +02:00
Roberto Redradix
7f43fc1d98 refactor(cli): extract adapters and a CSS outputter 2023-09-01 17:43:45 +02:00
Roberto Redradix
66f0b48fa4 refactor(cli): difference API and internal types
Take the opportunity to merge PentpotApiPage and PenpotApiObject into PenpotApiContainer to follow more closely the Penpot data model
2023-09-01 17:43:45 +02:00
Roberto Redradix
30494680a6 fix(cli): correctly validate undefined instance 2023-09-01 17:43:45 +02:00
Roberto Redradix
f53464baad chore(cli): remove residual console.log 2023-08-31 20:34:08 +02:00
Roberto Redradix
899a8b6572 docs: update configuration example 2023-08-31 20:28:14 +02:00
Roberto Redradix
6fbc1adace chore(cli): fix whitespace after emoji in logs
U+1F5BC FRAME WITH PICTURE requires appending a U+FE0F VARIATION SELECTOR-16 so that its emoji representation is forced. This causes terminal emulators to not reserve space for the next character. A hack consisting in using a U+00A0 NO-BREAK SPACE afterwards works, but copying the output and pasting it elsewhere will cause a double space.

Replacing U+1F5BC FRAME WITH PICTURE with another emoji that doesn't have a textual representation like U+1F3A8 ARTIST PALETTE solves this.
2023-08-31 20:23:27 +02:00
Roberto Redradix
d2540b3765 chore(cli): split validating user config from normalizing app config
Also, be more exhaustive with types and errors
2023-08-31 20:23:27 +02:00
Roberto Redradix
990260bf81 chore(cli): remove get-page call
Instead of making a new call to the Penpot API to retrieve page components, retrieve them from the Penpot file already downloaded.

Midway, it fixes some Penpot API types from arrays to records.
2023-08-31 20:23:27 +02:00
Roberto Redradix
ce380d99b7 feat(cli): redesign user config 2023-08-31 20:23:27 +02:00
Roberto Redradix
06b8da67fe feat(cli): support third-party Penpot instances 2023-08-30 13:34:40 +02:00
Roberto Redradix
3a61990e62 chore(demo): demonstrate colors CSS working in a web document 2023-08-29 18:14:02 +02:00
Roberto Redradix
e2812c99ea feat(cli): allow exporting colors CSS vars 2023-08-29 18:14:02 +02:00
Roberto Redradix
c5288352ab chore(demo): update typography demo and generated CSS 2023-08-29 17:23:04 +02:00
Roberto Redradix
ee2531f6c6 chore(cli)!: avoid non-obvious CSS class names clashing errors
As observed in fa873130, current classname PoC tranformation is prone to name clashing errors because it replaces everything not matching `/[a-zA-Z_-|0-9]/g` with underscores. However, as names from typography assets coming from Penpot can hold these values (and often they will, because designers consider emoji useful specially in asset names), the tranformation needed a more thorough algorhythm to avoid clashing errors.

This implementation follows the CSS specification and browser behaviours, which allow more than those characters in class names (including non-ASCII Unicode characters, and even escaped ASCII characters that CSS uses in its syntax), to output valid CSS class nameswith a minimum surface of clashing possibilities.

Since any transformation will decrease the entropy because CSS syntax is a subset of Unicode, there are inevitable clash zones, though. Those zones are reduced to two easily observable cases: duplicated names with explicit underscores instead of spaces, and duplicated names with surrounding whitespace; e.g. "My typography", "My_typography", " My typography" or "My typography " will clash if any pair of those ever happen together.

BREAKING CHANGE: class names generation is no longer case insensitive.
2023-08-29 17:23:04 +02:00
Roberto Redradix
d0e18709f1 chore(demo): demonstrate typography CSS working in a web document 2023-08-29 17:23:04 +02:00
Roberto Redradix
c201db2f2d chore(demo): generate typographies CSS 2023-08-29 17:23:04 +02:00