Skip to content

Commit

Permalink
Merge pull request #674 from pixiv/feat/mark-tokens-unstable
Browse files Browse the repository at this point in the history
feat: mark tokens unstable
  • Loading branch information
yue4u authored Dec 16, 2024
2 parents 5fa6444 + 5a62c71 commit 7534b89
Show file tree
Hide file tree
Showing 26 changed files with 33 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ LICENSE
/packages/token-cli/build/
/packages/token-cli/tokens/
/packages/token-cli/out/
/packages/theme/src/css/
/packages/theme/src/unstable-css/
/packages/react/docs/v4.0.0.mdx
4 changes: 2 additions & 2 deletions .storybook/theme-decorator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { useDarkMode } from 'storybook-dark-mode'
import { light, dark } from '@charcoal-ui/theme'
import { TokenInjector, themeSelector, themeSetter } from '@charcoal-ui/styled'

import '../packages/theme/src/css/_variables_dark.css'
import '../packages/theme/src/css/_variables_light.css'
import '../packages/theme/src/unstable-css/_variables_dark.css'
import '../packages/theme/src/unstable-css/_variables_light.css'
import '../packages/react/dist/index.css'

const setter = themeSetter()
Expand Down
2 changes: 1 addition & 1 deletion packages/react/docs/TokenV2DemoStyled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useState } from 'react'
import styled from 'styled-components'
// This does not work :(
// import tokens from '@charcoal-ui/theme/tokens/camel/css-variables.json'
import tokens from '../../theme/dist/tokens/camel/css-variables.json'
import tokens from '../../theme/dist/unstable-tokens/camel/css-variables.json'
import { Button, Icon } from '@charcoal-ui/react'

const categories = ['Illustration', 'Comic', 'Novel', '3D', 'Shopping']
Expand Down
2 changes: 1 addition & 1 deletion packages/tailwind-config/src/tokenV2.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import light from '@charcoal-ui/theme/tokens/css-variables.json'
import light from '@charcoal-ui/theme/unstable-tokens/css-variables.json'
import {
TailwindConfig,
TailwindThemeFontSizes,
Expand Down
21 changes: 12 additions & 9 deletions packages/theme/cli/token-object.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/* eslint-disable no-console */
import { readFileSync, mkdirSync, writeFileSync } from 'node:fs'
import path from 'node:path'
import { createCSSTokenObject, createTokenObject } from '../src/token-object'
import type { TokenDictionary } from '../src/token-object/types'
import { camelCaseKeys } from '../src/token-object'
import {
createCSSTokenObject,
createTokenObject,
} from '../src/unstable-token-object'
import type { TokenDictionary } from '../src/unstable-token-object/types'
import { camelCaseKeys } from '../src/unstable-token-object'

type ValueStyle = 'cssVariable'
type KeyStyle = 'camelCase'
Expand All @@ -20,45 +23,45 @@ const configurations: Config[] = [
{
tokenFile: './src/json/pixiv-light.json',
baseFile: './src/json/base.json',
outputFile: './dist/tokens/pixiv-light.json',
outputFile: './dist/unstable-tokens/pixiv-light.json',
keyStyle: undefined,
valueStyle: undefined,
},
{
tokenFile: './src/json/pixiv-dark.json',
baseFile: './src/json/base.json',
outputFile: './dist/tokens/pixiv-dark.json',
outputFile: './dist/unstable-tokens/pixiv-dark.json',
keyStyle: undefined,
valueStyle: undefined,
},

{
tokenFile: './src/json/pixiv-light.json',
baseFile: './src/json/base.json',
outputFile: './dist/tokens/camel/pixiv-light.json',
outputFile: './dist/unstable-tokens/camel/pixiv-light.json',
keyStyle: 'camelCase',
valueStyle: undefined,
},
{
tokenFile: './src/json/pixiv-dark.json',
baseFile: './src/json/base.json',
outputFile: './dist/tokens/camel/pixiv-dark.json',
outputFile: './dist/unstable-tokens/camel/pixiv-dark.json',
keyStyle: 'camelCase',
valueStyle: undefined,
},

{
tokenFile: './src/json/pixiv-light.json',
baseFile: './src/json/base.json',
outputFile: './dist/tokens/css-variables.json',
outputFile: './dist/unstable-tokens/css-variables.json',
keyStyle: undefined,
valueStyle: 'cssVariable',
},

{
tokenFile: './src/json/pixiv-light.json',
baseFile: './src/json/base.json',
outputFile: './dist/tokens/camel/css-variables.json',
outputFile: './dist/unstable-tokens/camel/css-variables.json',
keyStyle: 'camelCase',
valueStyle: 'cssVariable',
},
Expand Down
26 changes: 13 additions & 13 deletions packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@
"import": "./dist/index.esm.js",
"default": "./dist/index.esm.js"
},
"./token-object": {
"types": "./dist/token-object/index.d.ts",
"require": "./dist/token-object/index.cjs.js",
"import": "./dist/token-object/index.esm.js",
"default": "./dist/token-object/index.esm.js"
"./unstable-token-object": {
"types": "./dist/unstable-token-object/index.d.ts",
"require": "./dist/unstable-token-object/index.cjs.js",
"import": "./dist/unstable-token-object/index.esm.js",
"default": "./dist/unstable-token-object/index.esm.js"
},
"./css/*": "./dist/css/*",
"./tokens/*": "./dist/tokens/*"
"./unstable-css/*": "./dist/unstable-css/*",
"./unstable-tokens/*": "./dist/unstable-tokens/*"
},
"typesVersions": {
"*": {
"token-object": [
"unstable-token-object": [
"./dist/token-object/index.d.ts"
],
"tokens/*": [
"./dist/tokens/*"
"unstable-tokens/*": [
"./dist/unstable-tokens/*"
],
"css/*": [
"./dist/css/*"
"unstable-css/*": [
"./dist/unstable-css/*"
]
}
},
Expand All @@ -41,7 +41,7 @@
"build": "npm-run-all --print-label -s 'build:*' --sequential serialize",
"build:bundle": "FORCE_COLOR=1 tsup",
"build:dts": "tsc --project tsconfig.build.json --pretty --emitDeclarationOnly",
"build:copy-css": "cpx --clean 'src/css/**/*.{css,d.ts}' dist/css",
"build:copy-css": "cpx --clean 'src/unstable-css/**/*.{css,d.ts}' dist/unstable-css",
"build:token-object": "tsx cli/token-object.ts",
"serialize": "node cli/index.js",
"typecheck": "run-p --print-label 'typecheck:*'",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ describe.each([
})

describe.each([
['light theme', lightToken, '../css/_variables_light.css'],
['dark theme', darkToken, '../css/_variables_dark.css'],
['light theme', lightToken, '../unstable-css/_variables_light.css'],
['dark theme', darkToken, '../unstable-css/_variables_dark.css'],
] as const)(
'createCSSTokenObject test: %s',
async (description, token, cssFilePath) => {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/theme/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from 'tsup'
export default defineConfig({
entry: {
index: 'src/index.ts',
'token-object/index': 'src/token-object/index.ts',
'unstable-token-object/index': 'src/unstable-token-object/index.ts',
},
format: ['esm', 'cjs'],
outExtension({ format }) {
Expand Down

0 comments on commit 7534b89

Please sign in to comment.