Skip to content

Commit

Permalink
Update dependencies.
Browse files Browse the repository at this point in the history
Reorder Tailwind classes.
Update to Figma v19 (new AutoLayout).
  • Loading branch information
bernaferrari committed Nov 20, 2020
1 parent 904d83b commit 276a995
Show file tree
Hide file tree
Showing 17 changed files with 1,220 additions and 1,285 deletions.
67 changes: 34 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,58 @@
"author": "Bernardo Ferrari",
"license": "GPL-3.0",
"dependencies": {
"@figma/plugin-typings": "^1.16.1",
"clipboard-copy": "^3.1.0",
"@figma/plugin-typings": "^1.19.0",
"clipboard-copy": "^4.0.1",
"prism-theme-night-owl": "^1.4.0",
"sirv-cli": "^1.0.6",
"sirv-cli": "^1.0.8",
"svelte-prism": "^1.1.3",
"tailwindcss": "^1.8.10"
"tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.0.1"
},
"devDependencies": {
"@fullhuman/postcss-purgecss": "^3.0.0",
"@rollup/plugin-commonjs": "^15.1.0",
"@fullhuman/postcss-purgecss": "^2.3.0",
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-image": "^2.0.4",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-typescript": "^6.0.0",
"@types/jest": "^26.0.14",
"@types/node": "^14.11.1",
"@typescript-eslint/eslint-plugin": "^4.2.0",
"@typescript-eslint/parser": "^4.2.0",
"autoprefixer": "^10.0.0",
"@rollup/plugin-node-resolve": "^10.0.0",
"@rollup/plugin-typescript": "^6.1.0",
"@types/jest": "^26.0.15",
"@types/node": "^14.0.14",
"@typescript-eslint/eslint-plugin": "^4.8.1",
"@typescript-eslint/parser": "^4.8.1",
"autoprefixer": "^9.8.6",
"cross-env": "^7.0.2",
"css-loader": "^4.3.0",
"css-loader": "^3.6.0",
"cssnano": "^4.1.10",
"eslint": "^7.9.0",
"eslint": "^7.3.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-jest": "^24.0.2",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-prettier": "^3.1.4",
"figma-api-stub": "0.0.43",
"file-loader": "^6.1.0",
"jest": "^26.4.2",
"mini-css-extract-plugin": "^0.11.2",
"postcss": "^8.0.6",
"postcss-load-config": "^2.1.1",
"postcss-loader": "^4.0.2",
"prettier": "^2.1.2",
"rollup": "^2.28.1",
"figma-plugin-ds-svelte": "^1.0.7",
"file-loader": "^6.0.0",
"jest": "^26.1.0",
"mini-css-extract-plugin": "^0.9.0",
"postcss": "^7.0.32",
"postcss-load-config": "^2.1.0",
"postcss-loader": "^3.0.0",
"prettier": "^2.0.5",
"rollup": "^2.33.3",
"rollup-plugin-html-bundle": "0.0.3",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-postcss": "^3.1.8",
"rollup-plugin-postcss": "^2.5.0",
"rollup-plugin-purgecss": "^1.0.0",
"rollup-plugin-svelte": "^6.0.1",
"rollup-plugin-svelte": "^6.1.1",
"rollup-plugin-svg": "^2.0.0",
"rollup-plugin-terser": "^7.0.2",
"style-loader": "^1.2.1",
"svelte": "^3.25.1",
"style-loader": "^2.0.0",
"svelte": "^3.23.2",
"svelte-loader": "^2.13.6",
"svelte-preprocess": "^4.3.0",
"ts-jest": "^26.4.0",
"ts-loader": "^8.0.4",
"svelte-preprocess": "^4.6.0",
"ts-jest": "^26.1.1",
"ts-loader": "^8.0.11",
"ts-node": "^9.0.0",
"typescript": "^4.0.3",
"typescript": "^4.1.2",
"url-loader": "^4.1.0",
"webpack": "^4.44.2",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.12"
}
}
21 changes: 9 additions & 12 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@

const production = !process.env.ROLLUP_WATCH || process.env.PRODUCTION;

const tailwind = require('tailwindcss');
const tailwind = require("tailwindcss");

const autoprefixer = require('autoprefixer');
const autoprefixer = require("autoprefixer");

const purgecss = require('@fullhuman/postcss-purgecss')({
content: ['./src/**/*.svelte', './src/**/*.html'],
whitelistPatterns: [/svelte-/],
whitelistPatternsChildren: [/^token/, /^Prism/, /^code/, /^pre/],
defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g) || []
const purgecss = require("@fullhuman/postcss-purgecss")({
content: ["./src/**/*.svelte", "./src/**/*.html"],
whitelistPatterns: [/svelte-/],
whitelistPatternsChildren: [/^token/, /^Prism/, /^code/, /^pre/],
defaultExtractor: (content) => content.match(/[A-Za-z0-9-_:/]+/g) || [],
})

const cssnano = require('cssnano');
const cssnano = require("cssnano");

module.exports = {
plugins: [
tailwind,
...(production ? [autoprefixer, purgecss, cssnano] : [])
]
plugins: [tailwind, ...(production ? [autoprefixer, purgecss, cssnano] : [])],
}
168 changes: 83 additions & 85 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,102 +1,100 @@
import svelte from 'rollup-plugin-svelte';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import svg from 'rollup-plugin-svg';
import typescript from '@rollup/plugin-typescript';
import svelte from "rollup-plugin-svelte";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import livereload from "rollup-plugin-livereload";
import { terser } from "rollup-plugin-terser";
import svg from "rollup-plugin-svg";
import typescript from "@rollup/plugin-typescript";

/* Post CSS */
import postcss from 'rollup-plugin-postcss';
import tailwind from 'tailwindcss';
import cssnano from 'cssnano';
import postcss from "rollup-plugin-postcss";
import tailwind from "tailwindcss";
import cssnano from "cssnano";

/* Inline to single html */
import htmlBundle from 'rollup-plugin-html-bundle';
import htmlBundle from "rollup-plugin-html-bundle";

const production = !process.env.ROLLUP_WATCH || process.env.PRODUCTION;

export default [
{
input: 'src/main.js',
output: {
file: 'src/build/bundle.js',
format: 'iife',
name: 'ui'
},
plugins: [
svelte({
// enable run-time checks when not in production
dev: !production,
emitCss: true
}),
{
input: "src/main.js",
output: {
file: "src/build/bundle.js",
format: "iife",
name: "ui",
},
plugins: [
svelte({
// enable run-time checks when not in production
dev: !production,
emitCss: true,
}),

// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration —
// consult the documentation for details:¡
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: importee => importee === 'svelte' || importee.startsWith('svelte/'),
extensions: ['.svelte', '.ts', '.mjs', '.js', '.json', '.node']
}),
commonjs(),
svg(),
postcss({
extensions: ['.css'],
// extract: true,
plugins: [cssnano(), tailwind()]
}),
htmlBundle({
template: 'src/template.html',
target: 'public/index.html',
inline: true
}),
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration —
// consult the documentation for details:¡
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: (importee) =>
importee === "svelte" || importee.startsWith("svelte/"),
extensions: [".svelte", ".ts", ".mjs", ".js", ".json", ".node"],
}),
commonjs(),
svg(),
postcss({
extensions: [".css"],
// extract: true,
plugins: [cssnano(), tailwind()],
}),
htmlBundle({
template: "src/template.html",
target: "public/index.html",
inline: true,
}),

// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),
// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),

// Watch the `dist` directory and refresh the
// browser on changes when not in production
!production && livereload('public'),
// Watch the `dist` directory and refresh the
// browser on changes when not in production
!production && livereload("public"),

// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser()
],
watch: {
clearScreen: false
}
},
{
input: 'src/code.ts',
output: {
file: 'public/code.js',
format: 'cjs',
sourcemap: true,
},
plugins: [
typescript(),
commonjs(),
production && terser()
]
}];
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser(),
],
watch: {
clearScreen: false,
},
},
{
input: "src/code.ts",
output: {
file: "public/code.js",
format: "cjs",
sourcemap: true,
},
plugins: [typescript(), commonjs(), production && terser()],
},
];

function serve() {
let started = false;
let started = false;

return {
writeBundle() {
if (!started) {
started = true;
return {
writeBundle() {
if (!started) {
started = true;

require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true
});
}
}
};
require("child_process").spawn("npm", ["run", "start", "--", "--dev"], {
stdio: ["ignore", "inherit", "inherit"],
shell: true,
});
}
},
};
}
5 changes: 5 additions & 0 deletions src/altNodes/altConversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,17 @@ const convertLayout = (altNode: AltLayoutMixin, node: LayoutMixin) => {
altNode.height = node.height;
altNode.rotation = node.rotation;
altNode.layoutAlign = node.layoutAlign;
altNode.layoutGrow = node.layoutGrow;
};

const convertFrame = (altNode: AltFrameMixin, node: DefaultFrameMixin) => {
altNode.layoutMode = node.layoutMode;
altNode.primaryAxisSizingMode = node.primaryAxisSizingMode;
altNode.counterAxisSizingMode = node.counterAxisSizingMode;

altNode.primaryAxisAlignItems = node.primaryAxisAlignItems;
altNode.counterAxisAlignItems = node.counterAxisAlignItems;

altNode.paddingLeft = node.horizontalPadding;
altNode.paddingRight = node.horizontalPadding;
altNode.paddingTop = node.verticalPadding;
Expand Down
21 changes: 11 additions & 10 deletions src/altNodes/altMixins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface AltRectangleCornerMixin {

export interface AltBlendMixin {
opacity: number;
blendMode: BlendMode;
blendMode: "PASS_THROUGH" | BlendMode;
isMask: boolean;
effects: ReadonlyArray<Effect>;
effectStyleId: string;
Expand All @@ -49,22 +49,23 @@ export interface AltLayoutMixin {
width: number;
height: number;

layoutAlign: "MIN" | "CENTER" | "MAX" | "STRETCH"; // applicable only inside auto-layout frames
layoutAlign: "MIN" | "CENTER" | "MAX" | "STRETCH" | "INHERIT"; // applicable only inside auto-layout frames
layoutGrow: number;
}

export interface AltFrameMixin {
layoutMode: "NONE" | "HORIZONTAL" | "VERTICAL";
primaryAxisSizingMode: "FIXED" | "AUTO"; // applicable only if layoutMode != "NONE"
counterAxisSizingMode: "FIXED" | "AUTO"; // applicable only if layoutMode != "NONE"

// horizontal and vertical were replaced by individual padding in each direction.
// horizontalPadding: number; // applicable only if layoutMode != "NONE"
// verticalPadding: number; // applicable only if layoutMode != "NONE"
itemSpacing: number; // applicable only if layoutMode != "NONE"
primaryAxisAlignItems: "MIN" | "MAX" | "CENTER" | "SPACE_BETWEEN"; // applicable only if layoutMode != "NONE"
counterAxisAlignItems: "MIN" | "MAX" | "CENTER"; // applicable only if layoutMode != "NONE"

paddingRight: number;
paddingLeft: number;
paddingTop: number;
paddingBottom: number;
paddingLeft: number; // applicable only if layoutMode != "NONE"
paddingRight: number; // applicable only if layoutMode != "NONE"
paddingTop: number; // applicable only if layoutMode != "NONE"
paddingBottom: number; // applicable only if layoutMode != "NONE"
itemSpacing: number; // applicable only if layoutMode != "NONE"

layoutGrids: ReadonlyArray<LayoutGrid>;
gridStyleId: string;
Expand Down
2 changes: 1 addition & 1 deletion src/flutter/builderImpl/flutterColor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const flutterBoxDecorationColor = (
.map((d) => {
return rgbaToFlutterColor(d.color, d.color.a);
})
.join("");
.join(", ");

return `gradient: LinearGradient(${direction}, colors: [${colors}], ), `;
}
Expand Down
6 changes: 4 additions & 2 deletions src/ui/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
import ScreenFlutter from "./ScreenFlutter.svelte";
import ScreenSwiftUI from "./ScreenSwiftUI.svelte";
import ScreenAbout from "./ScreenAbout.svelte";
import { GlobalCSS } from 'figma-plugin-ds-svelte';
</script>

<style lang="postcss">
Expand Down Expand Up @@ -66,8 +69,7 @@
<div class="p-2">
<div class="fixed bottom-0 left-0 w-full px-2 mb-2">
<div
class="h-8 w-full flex items-center justify-center bg-green-600
rounded-lg"
class="flex items-center justify-center w-full h-8 bg-green-600 rounded-lg"
in:fly={{ y: 20, duration: 800 }}
out:fade>
<p class="text-white">Copied!</p>
Expand Down
Loading

0 comments on commit 276a995

Please sign in to comment.