diff --git a/.pnp.cjs b/.pnp.cjs index ec6031abc..dbaf5fb46 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -2182,7 +2182,8 @@ const RAW_RUNTIME_STATE = ["workspace:ui/theme", {\ "packageLocation": "./ui/theme/",\ "packageDependencies": [\ - ["@atls-ui/theme", "workspace:ui/theme"]\ + ["@atls-ui/theme", "workspace:ui/theme"],\ + ["csstype", "npm:3.2.3"]\ ],\ "linkType": "SOFT"\ }]\ diff --git a/ui-admin/theme/src/properties/typography.css.ts b/ui-admin/theme/src/properties/typography.css.ts index a7c02d806..94876416d 100644 --- a/ui-admin/theme/src/properties/typography.css.ts +++ b/ui-admin/theme/src/properties/typography.css.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography sprinkles after components are refactored to @atls-ui/theme typography. import { defineProperties } from 'rainbow-sprinkles' import { vars } from '../theme.css.js' diff --git a/ui-admin/theme/src/tokens/contract/colors.ts b/ui-admin/theme/src/tokens/contract/colors.ts index 482e6271b..2d76c18a6 100644 --- a/ui-admin/theme/src/tokens/contract/colors.ts +++ b/ui-admin/theme/src/tokens/contract/colors.ts @@ -1,6 +1,6 @@ export type ColorsTokens = Record -export const colorsContract = { +export const legacyColorsContract = { blue: null, blueProtective: null, white: null, @@ -42,3 +42,5 @@ export const colorsContract = { 'icons.placeholder': null, } + +export const colorsContract = legacyColorsContract diff --git a/ui-admin/theme/src/tokens/contract/font-sizes.ts b/ui-admin/theme/src/tokens/contract/font-sizes.ts index 797a45fb4..13c6f5d5a 100644 --- a/ui-admin/theme/src/tokens/contract/font-sizes.ts +++ b/ui-admin/theme/src/tokens/contract/font-sizes.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography tokens after components are refactored to @atls-ui/theme typography. export type FontSizesTokens = Record export const fontSizesContract = { diff --git a/ui-admin/theme/src/tokens/contract/font-weights.ts b/ui-admin/theme/src/tokens/contract/font-weights.ts index f115cfcfd..ae3122ea9 100644 --- a/ui-admin/theme/src/tokens/contract/font-weights.ts +++ b/ui-admin/theme/src/tokens/contract/font-weights.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography tokens after components are refactored to @atls-ui/theme typography. export type FontWeightsTokens = Record export const fontWeightsContract = { diff --git a/ui-admin/theme/src/tokens/contract/fonts.ts b/ui-admin/theme/src/tokens/contract/fonts.ts index b6cf5cc32..083c8aa81 100644 --- a/ui-admin/theme/src/tokens/contract/fonts.ts +++ b/ui-admin/theme/src/tokens/contract/fonts.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography tokens after components are refactored to @atls-ui/theme typography. export type FontsTokens = Record export const fontsContract = { diff --git a/ui-admin/theme/src/tokens/contract/line-heights.ts b/ui-admin/theme/src/tokens/contract/line-heights.ts index 231edd82b..66aa01443 100644 --- a/ui-admin/theme/src/tokens/contract/line-heights.ts +++ b/ui-admin/theme/src/tokens/contract/line-heights.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography tokens after components are refactored to @atls-ui/theme typography. export type LineHeightsTokens = Record export const lineHeightsContract = { diff --git a/ui-admin/theme/src/tokens/dark/colors.ts b/ui-admin/theme/src/tokens/dark/colors.ts index 98dc349b0..290668719 100644 --- a/ui-admin/theme/src/tokens/dark/colors.ts +++ b/ui-admin/theme/src/tokens/dark/colors.ts @@ -1,6 +1,6 @@ import type { ColorsTokens } from '../contract/index.js' -export const colors: ColorsTokens = { +export const legacyColors: ColorsTokens = { blue: 'rgba(65, 109, 223, 1)', blueProtective: 'rgba(24, 144 ,255, 1)', white: 'rgba(0, 0, 0, 1)', @@ -42,3 +42,5 @@ export const colors: ColorsTokens = { 'icons.placeholder': 'rgba(104, 110, 130, 1)', } + +export const colors = legacyColors diff --git a/ui-admin/theme/src/tokens/dark/font-sizes.ts b/ui-admin/theme/src/tokens/dark/font-sizes.ts index 886a20276..ad47be765 100644 --- a/ui-admin/theme/src/tokens/dark/font-sizes.ts +++ b/ui-admin/theme/src/tokens/dark/font-sizes.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography tokens after components are refactored to @atls-ui/theme typography. import type { FontSizesTokens } from '../index.js' export const fontSizes: FontSizesTokens = { diff --git a/ui-admin/theme/src/tokens/dark/font-weights.ts b/ui-admin/theme/src/tokens/dark/font-weights.ts index b144b72f0..a8567aac4 100644 --- a/ui-admin/theme/src/tokens/dark/font-weights.ts +++ b/ui-admin/theme/src/tokens/dark/font-weights.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography tokens after components are refactored to @atls-ui/theme typography. import type { FontWeightsTokens } from '../index.js' export const fontWeights: FontWeightsTokens = { diff --git a/ui-admin/theme/src/tokens/dark/fonts.css.ts b/ui-admin/theme/src/tokens/dark/fonts.css.ts index 18de37d91..019320371 100644 --- a/ui-admin/theme/src/tokens/dark/fonts.css.ts +++ b/ui-admin/theme/src/tokens/dark/fonts.css.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography tokens after components are refactored to @atls-ui/theme typography. import type { FontsTokens } from '../index.js' import { globalFontFace } from '@vanilla-extract/css' diff --git a/ui-admin/theme/src/tokens/dark/line-heights.ts b/ui-admin/theme/src/tokens/dark/line-heights.ts index b484fa571..3b244d138 100644 --- a/ui-admin/theme/src/tokens/dark/line-heights.ts +++ b/ui-admin/theme/src/tokens/dark/line-heights.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography tokens after components are refactored to @atls-ui/theme typography. import type { LineHeightsTokens } from '../index.js' export const lineHeights: LineHeightsTokens = { diff --git a/ui-admin/theme/src/tokens/light/colors.ts b/ui-admin/theme/src/tokens/light/colors.ts index 51a3b7868..ec246f107 100644 --- a/ui-admin/theme/src/tokens/light/colors.ts +++ b/ui-admin/theme/src/tokens/light/colors.ts @@ -1,4 +1,4 @@ -export const colors = { +export const legacyColors = { blue: 'rgba(65, 109, 223, 1)', blueProtective: 'rgba(24, 144 ,255, 1)', white: 'rgba(255, 255, 255, 1)', @@ -40,3 +40,5 @@ export const colors = { 'icons.placeholder': 'rgba(161, 170, 199, 1)', } + +export const colors = legacyColors diff --git a/ui-admin/theme/src/tokens/light/font-sizes.ts b/ui-admin/theme/src/tokens/light/font-sizes.ts index 886a20276..ad47be765 100644 --- a/ui-admin/theme/src/tokens/light/font-sizes.ts +++ b/ui-admin/theme/src/tokens/light/font-sizes.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography tokens after components are refactored to @atls-ui/theme typography. import type { FontSizesTokens } from '../index.js' export const fontSizes: FontSizesTokens = { diff --git a/ui-admin/theme/src/tokens/light/font-weights.ts b/ui-admin/theme/src/tokens/light/font-weights.ts index b144b72f0..a8567aac4 100644 --- a/ui-admin/theme/src/tokens/light/font-weights.ts +++ b/ui-admin/theme/src/tokens/light/font-weights.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography tokens after components are refactored to @atls-ui/theme typography. import type { FontWeightsTokens } from '../index.js' export const fontWeights: FontWeightsTokens = { diff --git a/ui-admin/theme/src/tokens/light/fonts.css.ts b/ui-admin/theme/src/tokens/light/fonts.css.ts index 18de37d91..019320371 100644 --- a/ui-admin/theme/src/tokens/light/fonts.css.ts +++ b/ui-admin/theme/src/tokens/light/fonts.css.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography tokens after components are refactored to @atls-ui/theme typography. import type { FontsTokens } from '../index.js' import { globalFontFace } from '@vanilla-extract/css' diff --git a/ui-admin/theme/src/tokens/light/line-heights.ts b/ui-admin/theme/src/tokens/light/line-heights.ts index b484fa571..3b244d138 100644 --- a/ui-admin/theme/src/tokens/light/line-heights.ts +++ b/ui-admin/theme/src/tokens/light/line-heights.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography tokens after components are refactored to @atls-ui/theme typography. import type { LineHeightsTokens } from '../index.js' export const lineHeights: LineHeightsTokens = { diff --git a/ui-parts/theme/src/properties/typography.css.ts b/ui-parts/theme/src/properties/typography.css.ts index c61cb4fa6..4dccf8b45 100644 --- a/ui-parts/theme/src/properties/typography.css.ts +++ b/ui-parts/theme/src/properties/typography.css.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography sprinkles after components are refactored to @atls-ui/theme typography. import { defineProperties } from 'rainbow-sprinkles' import { vars } from '../theme.css.js' diff --git a/ui-parts/theme/src/tokens/colors.ts b/ui-parts/theme/src/tokens/colors.ts index b56cb81c9..d80e36659 100644 --- a/ui-parts/theme/src/tokens/colors.ts +++ b/ui-parts/theme/src/tokens/colors.ts @@ -1,4 +1,4 @@ -export const colors = { +export const legacyColors = { blue: 'rgba(65, 109, 223, 1)', blueProtective: 'rgba(24, 144 ,255, 1)', white: 'rgba(255, 255, 255, 1)', @@ -85,3 +85,5 @@ export const colors = { 'text.softBlue': 'rgba(65, 109, 223, 1)', 'text.green': 'rgba(52, 197, 29, 1)', } + +export const colors = legacyColors diff --git a/ui-parts/theme/src/tokens/font-sizes.ts b/ui-parts/theme/src/tokens/font-sizes.ts index 46f2991c5..5e792f568 100644 --- a/ui-parts/theme/src/tokens/font-sizes.ts +++ b/ui-parts/theme/src/tokens/font-sizes.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography tokens after components are refactored to @atls-ui/theme typography. export const fontSizes = { inherit: 'inherit', max: '100%', diff --git a/ui-parts/theme/src/tokens/font-weights.ts b/ui-parts/theme/src/tokens/font-weights.ts index b7defe1f2..54bdc4fb9 100644 --- a/ui-parts/theme/src/tokens/font-weights.ts +++ b/ui-parts/theme/src/tokens/font-weights.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography tokens after components are refactored to @atls-ui/theme typography. export const fontWeights = { inherit: 'inherit', light: '300', diff --git a/ui-parts/theme/src/tokens/fonts.css.ts b/ui-parts/theme/src/tokens/fonts.css.ts index 1b88702e4..fa027b899 100644 --- a/ui-parts/theme/src/tokens/fonts.css.ts +++ b/ui-parts/theme/src/tokens/fonts.css.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography tokens after components are refactored to @atls-ui/theme typography. import { globalFontFace } from '@vanilla-extract/css' const nunitoSans = 'Nunito Sans' diff --git a/ui-parts/theme/src/tokens/line-heights.ts b/ui-parts/theme/src/tokens/line-heights.ts index bb2b4dd69..4806d1cdd 100644 --- a/ui-parts/theme/src/tokens/line-heights.ts +++ b/ui-parts/theme/src/tokens/line-heights.ts @@ -1,3 +1,4 @@ +// TODO: Remove legacy typography tokens after components are refactored to @atls-ui/theme typography. export const lineHeights = { micro: '0.5', extraMicro: '0.8', diff --git a/ui/theme/assets/fonts/science-gothic/ScienceGothic-300.ttf b/ui/theme/assets/fonts/science-gothic/ScienceGothic-300.ttf new file mode 100644 index 000000000..98240d764 Binary files /dev/null and b/ui/theme/assets/fonts/science-gothic/ScienceGothic-300.ttf differ diff --git a/ui/theme/assets/fonts/science-gothic/ScienceGothic-400.ttf b/ui/theme/assets/fonts/science-gothic/ScienceGothic-400.ttf new file mode 100644 index 000000000..90c186545 Binary files /dev/null and b/ui/theme/assets/fonts/science-gothic/ScienceGothic-400.ttf differ diff --git a/ui/theme/assets/fonts/science-gothic/ScienceGothic-500.ttf b/ui/theme/assets/fonts/science-gothic/ScienceGothic-500.ttf new file mode 100644 index 000000000..52a34273f Binary files /dev/null and b/ui/theme/assets/fonts/science-gothic/ScienceGothic-500.ttf differ diff --git a/ui/theme/assets/fonts/science-gothic/ScienceGothic-600.ttf b/ui/theme/assets/fonts/science-gothic/ScienceGothic-600.ttf new file mode 100644 index 000000000..53deb090c Binary files /dev/null and b/ui/theme/assets/fonts/science-gothic/ScienceGothic-600.ttf differ diff --git a/ui/theme/licenses/science-gothic/AUTHORS.txt b/ui/theme/licenses/science-gothic/AUTHORS.txt new file mode 100644 index 000000000..19dc41e00 --- /dev/null +++ b/ui/theme/licenses/science-gothic/AUTHORS.txt @@ -0,0 +1,8 @@ +# This is the official list of project authors for copyright purposes. +# This file is distinct from the CONTRIBUTORS.txt file. +# See the latter for an explanation. +# +# Names should be added to this file as: +# Name or Organization + +Google LLC diff --git a/ui/theme/licenses/science-gothic/OFL.txt b/ui/theme/licenses/science-gothic/OFL.txt new file mode 100644 index 000000000..e4feb8866 --- /dev/null +++ b/ui/theme/licenses/science-gothic/OFL.txt @@ -0,0 +1,95 @@ +Copyright 2024 Font Detective LLC + +This Font Software is licensed under the SIL Open Font License, Version 1.1, +with no Reserved Font Name. +This license is copied below, and is also available with a FAQ at: +https://openfontlicense.org/ + +ADDITIONAL non-font source files are licensed to others under the Apache 2.0 open source license (https://www.apache.org/licenses/LICENSE-2.0). + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/ui/theme/package.json b/ui/theme/package.json index 374d15741..ec7cba3a4 100644 --- a/ui/theme/package.json +++ b/ui/theme/package.json @@ -10,13 +10,18 @@ }, "main": "./src/index.ts", "files": [ - "dist" + "assets", + "dist", + "licenses" ], "scripts": { "build": "yarn library build", "prepack": "yarn run build", "postpack": "rm -rf dist" }, + "dependencies": { + "csstype": "3.2.3" + }, "publishConfig": { "access": "public", "exports": { diff --git a/ui/theme/src/index.ts b/ui/theme/src/index.ts index eb8a537c4..b7c7cc5f2 100644 --- a/ui/theme/src/index.ts +++ b/ui/theme/src/index.ts @@ -1 +1,2 @@ +export * from './theme.js' export * from './tokens/index.js' diff --git a/ui/theme/src/theme.ts b/ui/theme/src/theme.ts new file mode 100644 index 000000000..f76e12e48 --- /dev/null +++ b/ui/theme/src/theme.ts @@ -0,0 +1,21 @@ +import type { Colors } from './tokens/index.js' +import type { TypographyTokens } from './tokens/index.js' + +import { darkColors } from './tokens/index.js' +import { lightColors } from './tokens/index.js' +import { typography } from './tokens/index.js' + +export interface Theme { + colors: Colors + typography: TypographyTokens +} + +export const lightTheme: Theme = { + colors: lightColors, + typography, +} + +export const darkTheme: Theme = { + colors: darkColors, + typography, +} diff --git a/ui/theme/src/tokens/colors/dark.ts b/ui/theme/src/tokens/colors/dark.ts new file mode 100644 index 000000000..bc2f8469b --- /dev/null +++ b/ui/theme/src/tokens/colors/dark.ts @@ -0,0 +1,37 @@ +import type { Colors } from './interfaces.js' + +export const darkColors: Colors = { + action: { + base: '#5F8FFF', + hover: '#7AA7FF', + pressed: '#3F74FF', + disabled: '#5F8FFF', + subtle: '#394A6B', + }, + surface: { + base: '#111111', + subtle: '#171717', + muted: '#1F1F1F', + soft: '#FFFFFF', + inverse: '#F8F9FF', + }, + text: { + primary: '#F2F4F7', + secondary: '#C9D0DA', + tertiary: '#9AA3B2', + muted: '#6B7485', + inverse: '#121417', + }, + status: { + success: '#4AD27F', + warning: '#F2B84B', + error: '#FF5C5C', + info: '#5B8CFF', + }, + elevation: { + xs: '#00000059', + sm: '#00000066', + md: '#00000073', + lg: '#00000099', + }, +} diff --git a/ui/theme/src/tokens/colors/index.ts b/ui/theme/src/tokens/colors/index.ts new file mode 100644 index 000000000..1b5289fd1 --- /dev/null +++ b/ui/theme/src/tokens/colors/index.ts @@ -0,0 +1,3 @@ +export * from './dark.js' +export type * from './interfaces.js' +export * from './light.js' diff --git a/ui/theme/src/tokens/colors/interfaces.ts b/ui/theme/src/tokens/colors/interfaces.ts new file mode 100644 index 000000000..88cc7f333 --- /dev/null +++ b/ui/theme/src/tokens/colors/interfaces.ts @@ -0,0 +1,45 @@ +export interface Colors { + action: ActionColors + surface: SurfaceColors + text: TextColors + status: StatusColors + elevation: ElevationColors +} + +export interface ActionColors { + base: string + hover: string + pressed: string + disabled: string + subtle: string +} + +export interface SurfaceColors { + base: string + subtle: string + muted: string + soft: string + inverse: string +} + +export interface TextColors { + primary: string + secondary: string + tertiary: string + muted: string + inverse: string +} + +export interface StatusColors { + success: string + warning: string + error: string + info: string +} + +export interface ElevationColors { + xs: string + sm: string + md: string + lg: string +} diff --git a/ui/theme/src/tokens/colors/light.ts b/ui/theme/src/tokens/colors/light.ts new file mode 100644 index 000000000..68165a067 --- /dev/null +++ b/ui/theme/src/tokens/colors/light.ts @@ -0,0 +1,37 @@ +import type { Colors } from './interfaces.js' + +export const lightColors: Colors = { + action: { + base: '#1E56C7', + hover: '#1643A3', + pressed: '#12357F', + disabled: '#1E56C740', + subtle: '#6B86C8', + }, + surface: { + base: '#F8F9FF', + subtle: '#EFF1FF', + muted: '#D4D8F0', + soft: '#FFFFFF', + inverse: '#111111', + }, + text: { + primary: '#0C0F1E', + secondary: '#2A3152', + tertiary: '#6B7DB3', + muted: '#9BA8C8', + inverse: '#FFFFFF', + }, + status: { + success: '#10B981', + warning: '#F59E0B', + error: '#EF4444', + info: '#60A5FA', + }, + elevation: { + xs: '#00000014', + sm: '#0000001A', + md: '#0000001F', + lg: '#0000004D', + }, +} diff --git a/ui/theme/src/tokens/index.ts b/ui/theme/src/tokens/index.ts index 098b7aa2e..4cdf4e014 100644 --- a/ui/theme/src/tokens/index.ts +++ b/ui/theme/src/tokens/index.ts @@ -1,5 +1,7 @@ export * from './animations.js' +export * from './colors/index.js' export * from './opacities.js' export * from './radii.js' export * from './space.js' +export * from './typography/index.js' export * from './z-index.js' diff --git a/ui/theme/src/tokens/typography/fontFaces.ts b/ui/theme/src/tokens/typography/fontFaces.ts new file mode 100644 index 000000000..315cae1f9 --- /dev/null +++ b/ui/theme/src/tokens/typography/fontFaces.ts @@ -0,0 +1,37 @@ +import type { FontFace } from './interfaces.js' + +export const scienceGothicFontFamily = 'Science Gothic' + +const createFontSource = (fileName: string): string => + new URL(`../../../assets/fonts/science-gothic/${fileName}`, import.meta.url).toString() + +export const scienceGothicFontFaces: Array = [ + { + fontFamily: scienceGothicFontFamily, + fontStyle: 'normal', + fontWeight: 300, + fontDisplay: 'swap', + src: `url(${createFontSource('ScienceGothic-300.ttf')}) format('truetype')`, + }, + { + fontFamily: scienceGothicFontFamily, + fontStyle: 'normal', + fontWeight: 400, + fontDisplay: 'swap', + src: `url(${createFontSource('ScienceGothic-400.ttf')}) format('truetype')`, + }, + { + fontFamily: scienceGothicFontFamily, + fontStyle: 'normal', + fontWeight: 500, + fontDisplay: 'swap', + src: `url(${createFontSource('ScienceGothic-500.ttf')}) format('truetype')`, + }, + { + fontFamily: scienceGothicFontFamily, + fontStyle: 'normal', + fontWeight: 600, + fontDisplay: 'swap', + src: `url(${createFontSource('ScienceGothic-600.ttf')}) format('truetype')`, + }, +] diff --git a/ui/theme/src/tokens/typography/fontSizes.ts b/ui/theme/src/tokens/typography/fontSizes.ts new file mode 100644 index 000000000..448b9d6ab --- /dev/null +++ b/ui/theme/src/tokens/typography/fontSizes.ts @@ -0,0 +1,16 @@ +export const fontSizes = { + xs3: '10px', + xs2: '11px', + xs: '12px', + sm: '14px', + md: '16px', + lg: '18px', + xl: '20px', + xl2: '24px', + xl3: '28px', + xl4: '32px', + xl5: '40px', + xl6: '48px', +} as const + +export type FontSizesTokens = typeof fontSizes diff --git a/ui/theme/src/tokens/typography/fontWeights.ts b/ui/theme/src/tokens/typography/fontWeights.ts new file mode 100644 index 000000000..ed5cd51a6 --- /dev/null +++ b/ui/theme/src/tokens/typography/fontWeights.ts @@ -0,0 +1,8 @@ +export const fontWeights = { + thin: 300, + regular: 400, + medium: 500, + semiBold: 600, +} as const + +export type FontWeightsTokens = typeof fontWeights diff --git a/ui/theme/src/tokens/typography/index.ts b/ui/theme/src/tokens/typography/index.ts new file mode 100644 index 000000000..8d294d627 --- /dev/null +++ b/ui/theme/src/tokens/typography/index.ts @@ -0,0 +1,3 @@ +export * from './fontFaces.js' +export type * from './interfaces.js' +export * from './typography.js' diff --git a/ui/theme/src/tokens/typography/interfaces.ts b/ui/theme/src/tokens/typography/interfaces.ts new file mode 100644 index 000000000..f5448cd01 --- /dev/null +++ b/ui/theme/src/tokens/typography/interfaces.ts @@ -0,0 +1,9 @@ +import type { AtRule } from 'csstype' +import type { Properties } from 'csstype' + +export type FontFace = AtRule.FontFace + +export type TypographyProperties = Pick< + Properties, + 'fontFamily' | 'fontSize' | 'fontWeight' | 'letterSpacing' | 'lineHeight' +> diff --git a/ui/theme/src/tokens/typography/letterSpacings.ts b/ui/theme/src/tokens/typography/letterSpacings.ts new file mode 100644 index 000000000..a584ff2d9 --- /dev/null +++ b/ui/theme/src/tokens/typography/letterSpacings.ts @@ -0,0 +1,7 @@ +export const letterSpacings = { + md: '0', + lg: '0.25px', + xl: '0.5px', +} as const + +export type LetterSpacingsTokens = typeof letterSpacings diff --git a/ui/theme/src/tokens/typography/lineHeights.ts b/ui/theme/src/tokens/typography/lineHeights.ts new file mode 100644 index 000000000..5d6116743 --- /dev/null +++ b/ui/theme/src/tokens/typography/lineHeights.ts @@ -0,0 +1,14 @@ +export const lineHeights = { + xs3: '12px', + xs2: '16px', + xs: '20px', + sm: '24px', + md: '28px', + lg: '32px', + xl: '36px', + xl2: '40px', + xl3: '48px', + xl4: '56px', +} as const + +export type LineHeightsTokens = typeof lineHeights diff --git a/ui/theme/src/tokens/typography/typography.ts b/ui/theme/src/tokens/typography/typography.ts new file mode 100644 index 000000000..9e6d5cf76 --- /dev/null +++ b/ui/theme/src/tokens/typography/typography.ts @@ -0,0 +1,120 @@ +import { scienceGothicFontFaces } from './fontFaces.js' +import { scienceGothicFontFamily } from './fontFaces.js' +import { fontSizes } from './fontSizes.js' +import { fontWeights } from './fontWeights.js' +import { letterSpacings } from './letterSpacings.js' +import { lineHeights } from './lineHeights.js' +import { createTypographyStyle } from './utils/index.js' + +export const typography = { + fontFamily: scienceGothicFontFamily, + fontFaces: scienceGothicFontFaces, + display: { + lg: createTypographyStyle({ + fontSize: fontSizes.xl6, + lineHeight: lineHeights.xl4, + fontWeight: fontWeights.semiBold, + letterSpacing: letterSpacings.md, + }), + md: createTypographyStyle({ + fontSize: fontSizes.xl5, + lineHeight: lineHeights.xl3, + fontWeight: fontWeights.semiBold, + letterSpacing: letterSpacings.md, + }), + sm: createTypographyStyle({ + fontSize: fontSizes.xl4, + lineHeight: lineHeights.xl2, + fontWeight: fontWeights.semiBold, + letterSpacing: letterSpacings.md, + }), + }, + heading: { + lg: createTypographyStyle({ + fontSize: fontSizes.xl3, + lineHeight: lineHeights.xl, + fontWeight: fontWeights.medium, + letterSpacing: letterSpacings.md, + }), + md: createTypographyStyle({ + fontSize: fontSizes.xl2, + lineHeight: lineHeights.lg, + fontWeight: fontWeights.medium, + letterSpacing: letterSpacings.md, + }), + sm: createTypographyStyle({ + fontSize: fontSizes.xl, + lineHeight: lineHeights.md, + fontWeight: fontWeights.medium, + letterSpacing: letterSpacings.md, + }), + }, + title: { + lg: createTypographyStyle({ + fontSize: fontSizes.lg, + lineHeight: lineHeights.sm, + fontWeight: fontWeights.medium, + letterSpacing: letterSpacings.md, + }), + md: createTypographyStyle({ + fontSize: fontSizes.md, + lineHeight: lineHeights.sm, + fontWeight: fontWeights.medium, + letterSpacing: letterSpacings.md, + }), + }, + body: { + lg: createTypographyStyle({ + fontSize: fontSizes.md, + lineHeight: lineHeights.sm, + fontWeight: fontWeights.regular, + letterSpacing: letterSpacings.md, + }), + md: createTypographyStyle({ + fontSize: fontSizes.sm, + lineHeight: lineHeights.xs, + fontWeight: fontWeights.regular, + letterSpacing: letterSpacings.md, + }), + sm: createTypographyStyle({ + fontSize: fontSizes.xs, + lineHeight: lineHeights.xs2, + fontWeight: fontWeights.regular, + letterSpacing: letterSpacings.md, + }), + }, + label: { + lg: createTypographyStyle({ + fontSize: fontSizes.md, + lineHeight: lineHeights.xs, + fontWeight: fontWeights.medium, + letterSpacing: letterSpacings.lg, + }), + md: createTypographyStyle({ + fontSize: fontSizes.sm, + lineHeight: lineHeights.xs, + fontWeight: fontWeights.medium, + letterSpacing: letterSpacings.lg, + }), + sm: createTypographyStyle({ + fontSize: fontSizes.xs, + lineHeight: lineHeights.xs2, + fontWeight: fontWeights.medium, + letterSpacing: letterSpacings.lg, + }), + }, + caption: createTypographyStyle({ + fontSize: fontSizes.xs2, + lineHeight: lineHeights.xs2, + fontWeight: fontWeights.regular, + letterSpacing: letterSpacings.xl, + }), + overline: createTypographyStyle({ + fontSize: fontSizes.xs3, + lineHeight: lineHeights.xs3, + fontWeight: fontWeights.medium, + letterSpacing: letterSpacings.xl, + }), +} as const + +export type TypographyTokens = typeof typography diff --git a/ui/theme/src/tokens/typography/utils/createTypographyStyle.ts b/ui/theme/src/tokens/typography/utils/createTypographyStyle.ts new file mode 100644 index 000000000..9d51e02f3 --- /dev/null +++ b/ui/theme/src/tokens/typography/utils/createTypographyStyle.ts @@ -0,0 +1,17 @@ +import type { TypographyProperties } from '../interfaces.js' +import type { TypographyStyleOptions } from './interfaces.js' + +import { scienceGothicFontFamily } from '../fontFaces.js' + +export const createTypographyStyle = ({ + fontSize, + lineHeight, + fontWeight, + letterSpacing, +}: TypographyStyleOptions): TypographyProperties => ({ + fontFamily: scienceGothicFontFamily, + fontSize, + lineHeight, + fontWeight, + letterSpacing, +}) diff --git a/ui/theme/src/tokens/typography/utils/index.ts b/ui/theme/src/tokens/typography/utils/index.ts new file mode 100644 index 000000000..a697d308f --- /dev/null +++ b/ui/theme/src/tokens/typography/utils/index.ts @@ -0,0 +1 @@ +export * from './createTypographyStyle.js' diff --git a/ui/theme/src/tokens/typography/utils/interfaces.ts b/ui/theme/src/tokens/typography/utils/interfaces.ts new file mode 100644 index 000000000..4ac98784d --- /dev/null +++ b/ui/theme/src/tokens/typography/utils/interfaces.ts @@ -0,0 +1,19 @@ +import type { fontSizes } from '../fontSizes.js' +import type { fontWeights } from '../fontWeights.js' +import type { letterSpacings } from '../letterSpacings.js' +import type { lineHeights } from '../lineHeights.js' + +export type FontSizeValue = (typeof fontSizes)[keyof typeof fontSizes] + +export type LineHeightValue = (typeof lineHeights)[keyof typeof lineHeights] + +export type FontWeightValue = (typeof fontWeights)[keyof typeof fontWeights] + +export type LetterSpacingValue = (typeof letterSpacings)[keyof typeof letterSpacings] + +export interface TypographyStyleOptions { + fontSize: FontSizeValue + lineHeight: LineHeightValue + fontWeight: FontWeightValue + letterSpacing: LetterSpacingValue +} diff --git a/yarn.lock b/yarn.lock index b3efdb384..1ff202aa2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1143,6 +1143,8 @@ __metadata: "@atls-ui/theme@workspace:*, @atls-ui/theme@workspace:ui/theme": version: 0.0.0-use.local resolution: "@atls-ui/theme@workspace:ui/theme" + dependencies: + csstype: "npm:3.2.3" languageName: unknown linkType: soft @@ -7036,6 +7038,13 @@ __metadata: languageName: node linkType: hard +"csstype@npm:3.2.3, csstype@npm:^3.2.3": + version: 3.2.3 + resolution: "csstype@npm:3.2.3" + checksum: 10/ad41baf7e2ffac65ab544d79107bf7cd1a4bb9bab9ac3302f59ab4ba655d5e30942a8ae46e10ba160c6f4ecea464cc95b975ca2fefbdeeacd6ac63f12f99fe1f + languageName: node + linkType: hard + "csstype@npm:^3.0.2, csstype@npm:^3.0.7": version: 3.1.3 resolution: "csstype@npm:3.1.3" @@ -7043,13 +7052,6 @@ __metadata: languageName: node linkType: hard -"csstype@npm:^3.2.3": - version: 3.2.3 - resolution: "csstype@npm:3.2.3" - checksum: 10/ad41baf7e2ffac65ab544d79107bf7cd1a4bb9bab9ac3302f59ab4ba655d5e30942a8ae46e10ba160c6f4ecea464cc95b975ca2fefbdeeacd6ac63f12f99fe1f - languageName: node - linkType: hard - "damerau-levenshtein@npm:^1.0.8": version: 1.0.8 resolution: "damerau-levenshtein@npm:1.0.8"