Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
fonts package with fonts config
Oleg Isonen475546faf9a6
diff --git a/apps/designer/app/designer/shared/fonts-manager/fonts-manager.tsx b/apps/designer/app/designer/shared/fonts-manager/fonts-manager.tsxindex 39f2a0b9fb..4359318325 100644--- a/apps/designer/app/designer/shared/fonts-manager/fonts-manager.tsx+++ b/apps/designer/app/designer/shared/fonts-manager/fonts-manager.tsx@@ -7,15 +7,21 @@ import {TextField,} from "@webstudio-is/design-system";import { AssetUpload, PreviewAsset, useAssets } from "~/designer/shared/assets";+import { systemFonts } from "@webstudio-is/fonts";-const getItems = (assets: Array<Asset | PreviewAsset>) =>- assets.map((asset) => ({+const getItems = (assets: Array<Asset | PreviewAsset>) => {+ const system = systemFonts.map((item) => ({ label: item.font }));++ const uploaded = assets.map((asset) => ({label:"meta" in asset && "family" in asset.meta? asset.meta.family: asset.name,}));+ return [...system, ...uploaded];+};+type FontsManagerProps = {value: string;onChange: (value: string) => void;diff --git a/packages/fonts/LICENSE b/packages/fonts/LICENSEnew file mode 100644index 0000000000..1f6edad9a7--- /dev/null+++ b/packages/fonts/LICENSE@@ -0,0 +1,21 @@+MIT License++Copyright (c) 2022 Webstudio++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.diff --git a/packages/fonts/README.md b/packages/fonts/README.mdnew file mode 100644index 0000000000..8d83a493ea--- /dev/null+++ b/packages/fonts/README.md@@ -0,0 +1,3 @@+# Fonts utils++Fonts logic reusable across all systems.diff --git a/packages/fonts/package.json b/packages/fonts/package.jsonnew file mode 100644index 0000000000..8e68da636d--- /dev/null+++ b/packages/fonts/package.json@@ -0,0 +1,29 @@+{+ "name": "@webstudio-is/fonts",+ "version": "0.1.0",+ "description": "Fonts utils",+ "author": "Webstudio <[email protected]>",+ "homepage": "https://webstudio.is",+ "scripts": {+ "typecheck": "tsc --noEmit",+ "checks": "yarn typecheck && yarn lint",+ "dev": "tsup src/index.ts --format esm,cjs --watch --out-dir=lib",+ "build": "rm -fr lib && tsc",+ "lint": "eslint ./src --ext .ts,.tsx --max-warnings 0"+ },+ "dependencies": {},+ "devDependencies": {+ "@webstudio-is/jest-config": "*",+ "tsup": "^6.1.3",+ "typescript": "4.7.4"+ },+ "main": "lib/index.js",+ "types": "lib/index.d.ts",+ "files": [+ "lib/*",+ "README.md",+ "!*.test.*"+ ],+ "license": "MIT",+ "private": false+}diff --git a/packages/fonts/src/index.ts b/packages/fonts/src/index.tsnew file mode 100644index 0000000000..7d68ce9a01--- /dev/null+++ b/packages/fonts/src/index.ts@@ -0,0 +1,20 @@+export const systemFonts = [+ {+ font: "Arial",+ fallbacks: ["sans-serif"],+ },+ {+ font: "Times New Roman",+ fallbacks: ["serif"],+ },+ {+ font: "Courier New",+ fallbacks: ["monospace"],+ },+ {+ font: "system-ui",+ fallbacks: ["system-ui"],+ },+];++export const defaultFallback = "sans-serif";diff --git a/packages/fonts/tsconfig.json b/packages/fonts/tsconfig.jsonnew file mode 100644index 0000000000..6b67ca9bbf--- /dev/null+++ b/packages/fonts/tsconfig.json@@ -0,0 +1,12 @@+// Extends can't use node's resolution rn https://github.com/dividab/tsconfig-paths/issues/209#issuecomment-1177261091+{+ "extends": "../../node_modules/@webstudio-is/tsconfig/base.json",+ "include": ["./src/**/*.ts"],+ "compilerOptions": {+ "module": "commonjs",+ "target": "ES2020",+ "strict": true,+ "baseUrl": ".",+ "outDir": "./lib"+ }+}