Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(console): prepare and publish the design system #3127

Merged
merged 9 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ jobs:
name: wingconsoleserver
path: apps/wing-console/console/server/*.tgz

- name: Upload Wing Console Design System
uses: actions/upload-artifact@v3
with:
name: wingconsoledesignsystem
path: apps/wing-console/console/design-system/*.tgz

- name: Upload Wing Console UI
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -225,6 +231,7 @@ jobs:
HANGAR_WING_SPEC: "file:${{ github.workspace }}/wing/winglang-${{ needs.build.outputs.version }}.tgz"
HANGAR_WINGCONSOLE_APP_SPEC: "file:${{ github.workspace }}/wingconsoleapp/wingconsole-app-${{ needs.build.outputs.version }}.tgz"
HANGAR_WINGCONSOLE_SERVER_SPEC: "file:${{ github.workspace }}/wingconsoleserver/wingconsole-server-${{ needs.build.outputs.version }}.tgz"
HANGAR_WINGCONSOLE_DESIGN_SYSTEM_SPEC: "file:${{ github.workspace }}/wingconsoledesignsystem/wingconsole-design-system-${{ needs.build.outputs.version }}.tgz"
HANGAR_WINGCONSOLE_UI_SPEC: "file:${{ github.workspace }}/wingconsoleui/wingconsole-ui-${{ needs.build.outputs.version }}.tgz"
HANGAR_WINGCOMPILER_SPEC: "file:${{ github.workspace }}/wingcompiler/winglang-compiler-${{ needs.build.outputs.version }}.tgz"
HANGAR_WINGSDK_SPEC: "file:${{ github.workspace }}/wingsdk/winglang-sdk-${{ needs.build.outputs.version }}.tgz"
Expand Down Expand Up @@ -291,6 +298,7 @@ jobs:
HANGAR_WING_SPEC: "file:${{ github.workspace }}/target/wing/winglang-${{ needs.build.outputs.version }}.tgz"
HANGAR_WINGCONSOLE_APP_SPEC: "file:${{ github.workspace }}/target/wingconsoleapp/wingconsole-app-${{ needs.build.outputs.version }}.tgz"
HANGAR_WINGCONSOLE_SERVER_SPEC: "file:${{ github.workspace }}/target/wingconsoleserver/wingconsole-server-${{ needs.build.outputs.version }}.tgz"
HANGAR_WINGCONSOLE_DESIGN_SYSTEM_SPEC: "file:${{ github.workspace }}/target/wingconsoledesignsystem/wingconsole-design-system-${{ needs.build.outputs.version }}.tgz"
HANGAR_WINGCONSOLE_UI_SPEC: "file:${{ github.workspace }}/target/wingconsoleui/wingconsole-ui-${{ needs.build.outputs.version }}.tgz"
HANGAR_WINGCOMPILER_SPEC: "file:${{ github.workspace }}/target/wingcompiler/winglang-compiler-${{ needs.build.outputs.version }}.tgz"
HANGAR_WINGSDK_SPEC: "file:${{ github.workspace }}/target/wingsdk/winglang-sdk-${{ needs.build.outputs.version }}.tgz"
Expand Down Expand Up @@ -417,6 +425,15 @@ jobs:
working-directory: wingcompiler
run: npm publish *.tgz --access public

- name: Publish Wing Console Design System
if: ${{ steps.wingconsoledesignsystem-version.outputs.version != needs.build.outputs.version }}
working-directory: wingconsoledesignsystem
run: npm publish *.tgz --access public

- name: Check published Wing Console Design System version
id: wingconsoledesignsystem-version
run: echo "version=$(npm view @wingconsole/design-system version)" >> $GITHUB_OUTPUT

- name: Check published Wing Console UI version
id: wingconsoleui-version
run: echo "version=$(npm view @wingconsole/ui version)" >> $GITHUB_OUTPUT
Expand Down
3 changes: 1 addition & 2 deletions apps/wing-console/console/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

194 changes: 4 additions & 190 deletions apps/wing-console/console/app/tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -1,195 +1,9 @@
const colors = require("tailwindcss/colors");
const defaultTheme = require("tailwindcss/defaultTheme");
const flattenColorPalette = require("tailwindcss/lib/util/flattenColorPalette");
const toColorValue = require("tailwindcss/lib/util/toColorValue");
const plugin = require("tailwindcss/plugin");

/**
* Extracts the value of the RGB components an hexadecimal color.
* @param {string} color
* @returns {[number, number, number]} The decimal value of the RGB components
*/
const rgbFromColor = (color) => [
Number.parseInt(color.slice(1, 3), 16),
Number.parseInt(color.slice(3, 5), 16),
Number.parseInt(color.slice(5, 7), 16),
];

/**
* Returns the value between two numbers.
* @param {number} value1
* @param {number} value2
* @returns
*/
const mixColorComponent = (value1, value2) => {
const max = Math.max(value1, value2);
const min = Math.min(value1, value2);
return Math.round(min + (max - min) / 2);
};

/**
* Mix two hexadecimal colors.
* @param {string} color1
* @param {string} color2
* @returns The mixed hexadecimal color.
* @example ```ts
* const color = mixColor("#666666", "#888888"); // "#777777"
* ```
*/
const mixColor = (color1, color2) => {
const rgb1 = rgbFromColor(color1);
const rgb2 = rgbFromColor(color2);
const r = mixColorComponent(rgb1[0], rgb2[0]);
const g = mixColorComponent(rgb1[1], rgb2[1]);
const b = mixColorComponent(rgb1[2], rgb2[2]);
return `#${r.toString(16)}${g.toString(16)}${b.toString(16)}`;
};

const expandColor = (color) => {
return {
...color,
150: mixColor(color[100], color[200]),
250: mixColor(color[200], color[300]),
350: mixColor(color[300], color[400]),
450: mixColor(color[400], color[500]),
550: mixColor(color[500], color[600]),
650: mixColor(color[600], color[700]),
750: mixColor(color[700], color[800]),
850: mixColor(color[800], color[900]),
};
};
const ui = require("@wingconsole/ui/tailwind-plugin.cjs");

/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: "class",
content: [
"./index.html",
"./src/**/*.{vue,js,ts,jsx,tsx}",
"../ui/src/**/*.{vue,js,ts,jsx,tsx}",
"../design-system/src/**/*.{vue,js,ts,jsx,tsx}",
],
theme: {
fontFamily: {
...defaultTheme.fontFamily,
sans: ["IBM Plex Sans", ...defaultTheme.fontFamily.sans],
mono: ["IBM Plex Mono", ...defaultTheme.fontFamily.mono],
"share-tech": ["Share Tech Mono", ...defaultTheme.fontFamily.mono],
},

extend: {
colors: {
gray: expandColor(colors.gray),
slate: expandColor(colors.slate),
"monada-light": "#AEF8EC",
"monada-dark": "#2ad5c1",
"monada-black": "#03120E",
},
fontSize: {
"2xs": "0.7rem",
},
},
},
plugins: [
require("@tailwindcss/forms"),
// Scrollbar plugin.
plugin(function ({ addUtilities, matchUtilities, addBase, theme }) {
addBase({
".scrollbar": {
"&": {
"border-color": "rgba(0, 0, 0, 0)",
},
"&::-webkit-scrollbar, &::-webkit-scrollbar-thumb, &::-webkit-scrollbar-corner":
{
// add border to act as background-color
"border-right-style": "inset",
// sum viewport dimensions to guarantee border will fill scrollbar
"border-right-width": "calc(100vw + 100vh)",
// inherit border-color to inherit transitions
"border-color": "inherit",
},
},
});

const themeColors = flattenColorPalette.default(theme("colors"));
const colors = Object.fromEntries(
Object.entries(themeColors).map(([k, v]) => [
k,
toColorValue.default(v),
]),
);
matchUtilities(
{
"scrollbar-bg": (value) => ({
"border-color": value,
}),
"scrollbar-thumb": (value) => ({
"&::-webkit-scrollbar-thumb": {
"border-color": value,
},
}),
"scrollbar-thumb-hover": (value) => ({
"&::-webkit-scrollbar-thumb:hover, &:hover::-webkit-scrollbar-thumb:hover":
{
"border-color": value,
},
}),
"scrollbar-thumb-active": (value) => ({
"&::-webkit-scrollbar-thumb:active, &:hover::-webkit-scrollbar-thumb:active":
{
"border-color": value,
},
}),
},
{ values: colors, type: "color" },
);

const themeWidths = flattenColorPalette.default(theme("width"));
const widths = Object.entries(themeWidths).filter(
([, size]) => size.endsWith("px") || size.endsWith("rem"),
);
matchUtilities(
{
"scrollbar-w": (value) => ({
"&::-webkit-scrollbar": {
width: Array.isArray(value) ? value[1] : value,
},
}),
},
{
values: widths,
type: ["absolute-size", "length"],
},
);

const themeHeights = flattenColorPalette.default(theme("height"));
const heights = Object.entries(themeHeights).filter(
([, size]) => size.endsWith("px") || size.endsWith("rem"),
);
matchUtilities(
{
"scrollbar-h": (value) => ({
"&::-webkit-scrollbar": {
height: Array.isArray(value) ? value[1] : value,
},
}),
},
{
values: heights,
type: ["absolute-size", "length"],
},
);

addUtilities({
".overflow-overlay": {
overflow: ["scroll", "overlay"],
},
".overflow-x-overlay": {
"overflow-x": ["scroll", "overlay"],
},
".overflow-y-overlay": {
"overflow-y": ["scroll", "overlay"],
},
});
}),
],
content: [...ui.content, "./index.html", "./src/**/*.{vue,js,ts,jsx,tsx}"],
plugins: [...ui.plugins],
theme: { ...ui.theme },
};
Loading
Loading