Skip to content

Commit

Permalink
fix: update config (#23)
Browse files Browse the repository at this point in the history
* feat(icons): itegrate icons poc [KHCP-7647]

* chore: add comments

* refactor: config file

* fix: scss mixin

* chore: progress

* chore: progress

* revert: remove icons

* chore: rename format
  • Loading branch information
adamdehaven authored Jun 14, 2023
1 parent d094081 commit d1dad34
Show file tree
Hide file tree
Showing 27 changed files with 75 additions and 120 deletions.
Binary file removed assets/fonts/Inter/Inter-Bold.ttf
Binary file not shown.
Binary file removed assets/fonts/Inter/Inter-Medium.ttf
Binary file not shown.
Binary file removed assets/fonts/Inter/Inter-Regular.ttf
Binary file not shown.
Binary file removed assets/fonts/Inter/Inter-SemiBold.ttf
Binary file not shown.
Binary file removed assets/fonts/JetBrainsMono/JetBrainsMono-Bold.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed assets/fonts/JetBrainsMono/JetBrainsMono-Italic.ttf
Binary file not shown.
Binary file removed assets/fonts/JetBrainsMono/JetBrainsMono-Light.ttf
Binary file not shown.
Binary file not shown.
Binary file removed assets/fonts/JetBrainsMono/JetBrainsMono-Medium.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed assets/fonts/JetBrainsMono/JetBrainsMono-Thin.ttf
Binary file not shown.
Binary file not shown.
135 changes: 53 additions & 82 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ const config = {
const customFileHeader = (defaultMessage) => {
return [
...defaultMessage,
'Source: https://github.com/Kong/design-system',
'Author: Kong, Inc.',
'License: Apache-2.0',
'GitHub: https://github.com/Kong/design-system',
]
}

Expand All @@ -35,18 +37,30 @@ const customFileHeader = (defaultMessage) => {
* Example:
* ```css
* .custom-container {
* @include kong-css-variables;
* @include kui-css-variables;
* }
* ```
*/
const { fileHeader, formattedVariables } = StyleDictionary.formatHelpers
StyleDictionary.registerFormat({
name: 'cssVariablesMixin',
name: 'css/variables/custom/sass/mixin',
formatter: function({ dictionary, file, options }) {
const { outputReferences } = options

return fileHeader({ file }) +
'@mixin kong-css-variables {\n' +
'/**\n' +
' * @kui-css-variables\n' +
' * Create a custom format to utilize CSS variables inside a SCSS mixin, which allows you to\n' +
' * scope the CSS variables inside of a custom selector. Example usage in https://github.com/Kong/kong-auth-elements \n' +
' *\n' +
' * Example:\n' +
' * ```css\n' +
' * .custom-container {\n' +
' * @include kui-css-variables;\n' +
' * }\n' +
' * ```\n' +
'*/\n' +
'@mixin kui-css-variables {\n' +
formattedVariables({ format: 'css', dictionary, outputReferences }) +
'\n}\n'
},
Expand All @@ -55,11 +69,16 @@ StyleDictionary.registerFormat({
// Create an empty platforms object
const platforms = {}

// CSS variables
/**
* CSS Variables
*/
platforms.css = {
prefix: KONG_TOKEN_PREFIX,
prefix: KONG_TOKEN_PREFIX, // required
transformGroup: 'css',
buildPath: `${TOKEN_DIRECTORY}/css/`,
options: {
fileHeader: customFileHeader,
},
transforms: [
'attribute/cti',
'name/cti/kebab',
Expand All @@ -70,20 +89,24 @@ platforms.css = {
destination: 'variables.css',
format: 'css/variables',
options: {
fileHeader: customFileHeader,
selector: ':root', // You can override the default selector; may be necessary for consumers (e.g. Kongponents)
},
// Exclude alias tokens
filter: (token) => token.isSource === true,
// Exclude alias tokens and asset tokens compiled in a separate file
filter: (token) => token.isSource === true && token.attributes.category !== 'asset',
},
],
}

// SCSS variables
/**
* SCSS Variables
*/
platforms.scss = {
prefix: KONG_TOKEN_PREFIX,
prefix: KONG_TOKEN_PREFIX, // required
transformGroup: 'scss',
buildPath: `${TOKEN_DIRECTORY}/scss/`,
options: {
fileHeader: customFileHeader,
},
transforms: [
'attribute/cti',
'name/cti/kebab',
Expand All @@ -94,30 +117,31 @@ platforms.scss = {
{
destination: '_variables.scss',
format: 'scss/variables',
options: {
fileHeader: customFileHeader,
},
// Exclude alias tokens
filter: (token) => token.isSource === true,
// Exclude alias tokens and asset tokens compiled in a separate file
filter: (token) => token.isSource === true && token.attributes.category !== 'asset',
},
// SCSS CSS variables mixin
{
destination: '_mixins.scss',
format: 'cssVariablesMixin',
options: {
fileHeader: customFileHeader,
},
// Exclude alias tokens
filter: (token) => token.isSource === true,
format: 'css/variables/custom/sass/mixin',
// Exclude alias tokens and asset tokens compiled in a separate file
filter: (token) => token.isSource === true && token.attributes.category !== 'asset',
},
],
}

// JavaScript
/**
* JavaScript Variables
*
* Important: Every exported file in this platform key **must** have a corresponding TypeScript declaration export.
*/
platforms.javascript = {
prefix: KONG_TOKEN_PREFIX,
prefix: KONG_TOKEN_PREFIX, // required
transformGroup: 'js',
buildPath: `${TOKEN_DIRECTORY}/js/`,
options: {
fileHeader: customFileHeader,
},
transforms: [
'attribute/cti',
'name/cti/constant',
Expand All @@ -128,71 +152,18 @@ platforms.javascript = {
{
destination: 'index.js',
format: 'javascript/es6',
options: {
fileHeader: customFileHeader,
},
// Exclude alias tokens
filter: (token) => token.isSource === true,
// Exclude alias tokens and asset tokens compiled in a separate file
filter: (token) => token.isSource === true && token.attributes.category !== 'asset',
},
// TypeScript types
// Constants TypeScript types
{
destination: 'index.d.ts',
format: 'typescript/es6-declarations',
options: {
fileHeader: customFileHeader,
outputStringLiterals: true,
},
// Exclude alias tokens
filter: (token) => token.isSource === true,
},
],
}

// Font families
platforms['assets/embed/scss'] = {
transforms: [
'attribute/cti',
'name/cti/kebab',
'asset/base64',
],
buildPath: `${TOKEN_DIRECTORY}/scss/`,
files: [
{
destination: '_fonts.scss',
format: 'scss/variables',
options: {
fileHeader: customFileHeader,
},
filter: {
attributes: {
category: 'asset',
type: 'font',
},
},
},
],
}

platforms['assets/embed/css'] = {
transforms: [
'attribute/cti',
'name/cti/kebab',
'asset/base64',
],
buildPath: `${TOKEN_DIRECTORY}/css/`,
files: [
{
destination: 'fonts.css',
format: 'css/variables',
options: {
fileHeader: customFileHeader,
},
filter: {
attributes: {
category: 'asset',
type: 'font',
},
},
// Exclude alias tokens and asset tokens compiled in a separate file
filter: (token) => token.isSource === true && token.attributes.category !== 'asset',
},
],
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Kong UI Design Tokens and style dictionary",
"scripts": {
"build": "yarn build:clean && style-dictionary build",
"build:clean": "style-dictionary clean",
"build:clean": "rimraf ./dist",
"lint": "eslint '**/*.{js,ts,vue,json}'",
"lint:fix": "eslint '**/*.{js,ts,vue,json}' --fix",
"sandbox": "run-p sandbox:open watch:tokens",
Expand Down Expand Up @@ -56,6 +56,7 @@
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-vue": "^9.14.1",
"npm-run-all": "^4.1.5",
"rimraf": "^5.0.1",
"sass": "^1.62.1",
"semantic-release": "^20.1.0",
"style-dictionary": "^3.8.0",
Expand Down
16 changes: 16 additions & 0 deletions sandbox/App.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<template>
<router-view />
</template>

<style lang="scss">
// Import CSS variables
@import "../dist/tokens/css/variables.css";
html,
body {
font-family: var(--kui-font-family-text, 'Inter', sans-serif);
margin: var(--kui-space-0);
padding: var(--kui-space-0);
}
body {
padding: var(--kui-space-20) var(--kui-space-40);
}
</style>
14 changes: 3 additions & 11 deletions sandbox/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,10 @@
<title>Design System Sandbox</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono&display=swap"
rel="stylesheet">
<!-- Files from the `../` directory are served at the root -->
<!-- Import CSS variables from vite public -->
<link href="/dist/tokens/css/variables.css" rel="stylesheet">
<style>
html,
body {
font-family: var(--kui-font-family-text, 'Inter', sans-serif);
margin: 0;
padding: 0;
}
</style>
</head>

<body>
Expand Down
1 change: 1 addition & 0 deletions sandbox/pages/HomeView.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<template>
<h2>Colors</h2>
<ColorBlock token="kui-color-background-primary" />
<ColorBlock token="kui-color-background-warning-weakest" />
<ColorBlock token="kui-color-background-danger" />
Expand Down
1 change: 0 additions & 1 deletion sandbox/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default defineConfig({
// Reload the Vite sandbox when any of the `/dist/*` files are changed
'../dist/**/*',
],
delay: 200,
}),
],
resolve: {
Expand Down
25 changes: 0 additions & 25 deletions tokens/source/assets/fonts.json

This file was deleted.

0 comments on commit d1dad34

Please sign in to comment.