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

Changes for Oct 25 demo #114

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
34 changes: 34 additions & 0 deletions package/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Contains information from the language-subtag-registry JSON Database (https://github.com/mattcg/language-subtag-registry/tree/master/data/json)
which is made available under the ODC Attribution License (https://github.com/mattcg/language-subtag-registry/blob/master/LICENSE.md).

The files listed in this repository are licensed under the below license. All other features and products are subject to separate agreements
and certain functionality requires paid subscriptions to Yext products.

BSD 3-Clause License

Copyright (c) 2024, Yext

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 changes: 27 additions & 0 deletions package/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
![Yext](yext.svg)

# visual-editor

This library provides components necessary to set up a Pages repository that can interact with Visual Editor in the Yext platform.

## Hooks

| Hook |
| ------------------------------------------------------------------------------------ |
| [usePlatformBridgeDocument](./src/hooks/README.md#usePlatformBridgeDocument) |
| [usePlatformBridgeEntityFields](./src/hooks/README.md#usePlatformBridgeEntityFields) |

## Components

| Component |
| ----------------------------------------------------------------------- |
| [Editor](src/editor/README.md#editor) |
| [EntityField](src/editor/README.md#entityfield) |
| [YextEntityFieldSelector](src/editor/README.md#YextEntityFieldSelector) |

## Utils

| Function |
| ------------------------------------------------------------------------ |
| [resolveVisualEditorData](./src/utils/README.md#resolvevisualeditordata) |
| [resolveYextEntityField](./src/utils/README.md#resolveYextEntityField) |
117 changes: 117 additions & 0 deletions package/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"name": "@yext/visual-editor",
"description": "Component library for Yext Pages Visual Editor",
"version": "0.0.13",
"type": "module",
"author": "sumo@yext.com",
"types": "dist/index.d.ts",
"main": "dist/visual-editor.cjs",
"module": "dist/visual-editor.js",
"sideEffects": false,
"files": [
"dist"
],
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/visual-editor.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/visual-editor.cjs"
}
},
"./style.css": "./dist/style.css"
},
"dependencies": {
"@measured/puck": "0.16.0",
"@radix-ui/react-alert-dialog": "^1.1.1",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-progress": "^1.1.0",
"@radix-ui/react-radio-group": "^1.2.1",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-switch": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.2",
"@yext/eslint-config": "^1.0.0",
"@yext/pages-components": "^1.0.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"eslint": "^9.8.0",
"eslint-plugin-react": "^7.35.0",
"lucide-react": "^0.414.0",
"next-themes": "^0.3.0",
"package.json": "^2.0.1",
"picocolors": "^1.0.1",
"prettier": "^3.3.3",
"prompts": "^2.4.2",
"react-color": "^2.19.3",
"sonner": "^1.5.0",
"tailwind-merge": "^2.4.0",
"tailwindcss-animate": "^1.0.7",
"ts-node": "^10.9.2",
"tsx": "^4.16.3"
},
"engines": {
"node": "^17 || ^18 || ^20"
},
"packageManager": "pnpm@8.6.8",
"lint-staged": {
"*": "prettier --write --cache --ignore-unknown",
"*.{ts,js,tsx,jsx}": "eslint --cache --fix"
},
"devDependencies": {
"@eslint/compat": "^1.1.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.8.0",
"@tailwindcss/typography": "^0.5.13",
"@testing-library/dom": "^10.4.0",
"@testing-library/react": "^16.0.1",
"@types/fs-extra": "^11.0.4",
"@types/minimist": "^1.2.5",
"@types/node": "^20.14.11",
"@types/prompts": "^2.4.9",
"@types/react": "^18.3.3",
"@types/react-color": "^3.0.12",
"@types/react-dom": "^18.3.0",
"@types/semver": "^7.5.8",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^8.0.1",
"@typescript-eslint/parser": "^8.0.1",
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^10.4.19",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-require-extensions": "^0.1.3",
"execa": "^8.0.1",
"fs-extra": "^11.2.0",
"generate-license-file": "^3.5.0",
"globals": "^15.8.0",
"husky": "^9.1.4",
"jsdom": "^24.1.1",
"lint-staged": "^15.2.7",
"minimist": "^1.2.8",
"postcss": "^8.4.39",
"prettier-plugin-tailwindcss": "^0.6.5",
"semver": "^7.6.3",
"tailwindcss": "^3.4.6",
"tsup": "^8.2.3",
"typescript": "^5.5.4",
"vite": "^5.3.5",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^2.0.5"
},
"peerDependencies": {
"react": "^17.0.2 || ^18.2.0",
"react-dom": "^17.0.2 || ^18.2.0"
},
"scripts": {
"build": "tsc && vite build",
"test": "vitest run",
"prettier": "prettier --write --cache .",
"lint": "eslint --cache --fix src/ scripts/",
"autofix": "pnpm run lint && pnpm run prettier",
"ci-publish": "tsx scripts/publishCI.ts",
"release": "tsx scripts/release.ts",
"generate-notices": "generate-license-file"
}
}
14 changes: 7 additions & 7 deletions src/components/puck/HeadingText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ const headingTextFields: Fields<HeadingTextProps> = {
{ label: "Black", value: "black" },
],
},
size: {
label: "Text Size",
type: "number",
min: 1,
},
// size: {
// label: "Text Size",
// type: "number",
// min: 1,
// },
color: {
type: "select",
options: [
Expand Down Expand Up @@ -96,8 +96,8 @@ export const HeadingTextComponent: ComponentConfig<HeadingTextProps> = {
},
content: "Heading",
level: 2,
weight: "default",
color: "default",
weight: "bold",
color: "primary",
transform: "none",
},
render: (props) => <HeadingText {...props} />,
Expand Down
30 changes: 14 additions & 16 deletions src/components/puck/atoms/heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "../../../internal/utils/cn.ts";

// Define the variants for the heading component
const headingVariants = cva("font-bold", {
const headingVariants = cva("py-4", {
variants: {
level: {
1: "font-heading1 text-heading1-fontSize text-heading1-color",
2: "font-heading2 text-heading2-fontSize text-heading2-color",
1: "ve-text-[48px]",
2: "ve-text-[24px]",
3: "font-heading3 text-heading3-fontSize text-heading3-color",
4: "font-heading4 text-heading4-fontSize text-heading4-color",
5: "font-heading5 text-heading5-fontSize text-heading5-color",
Expand All @@ -26,12 +26,10 @@ const headingVariants = cva("font-bold", {
black: "ve-font-black",
},
color: {
default: "",
primary: "text-primary",
secondary: "text-secondary",
accent: "text-accent",
text: "text-text",
background: "text-primary-background",
primary: "text-header-primary",
secondary: "text-header-secondary",
accent: "text-header-accent",
text: "text-header-text",
},
transform: {
none: "",
Expand All @@ -41,7 +39,7 @@ const headingVariants = cva("font-bold", {
},
},
defaultVariants: {
color: "default",
color: "primary",
weight: "default",
transform: "none",
},
Expand All @@ -55,19 +53,19 @@ export interface HeadingProps
extends Omit<React.HTMLAttributes<HTMLHeadingElement>, "color">,
VariantProps<typeof headingVariants> {
level?: HeadingLevel;
size?: number;
// size?: number;
}

const Heading = React.forwardRef<HTMLHeadingElement, HeadingProps>(
({ className, level = 1, size, color, weight, transform, ...props }, ref) => {
({ className, level = 1, color, weight, transform, ...props }, ref) => {
const Tag = `h${level}` as keyof Pick<
JSX.IntrinsicElements,
"h1" | "h2" | "h3" | "h4" | "h5" | "h6"
>;

const dynamicStyles = {
fontSize: size ? size + "px" : undefined,
};
// const dynamicStyles = {
// fontSize: size ? size + "px" : undefined,
// };

return (
<Tag
Expand All @@ -77,7 +75,7 @@ const Heading = React.forwardRef<HTMLHeadingElement, HeadingProps>(
cn(headingVariants({ color, className, weight, transform, level }))
}
ref={ref}
style={dynamicStyles ?? ""}
// style={dynamicStyles ?? ""}
{...props}
>
{props.children}
Expand Down
Loading