diff --git a/package-lock.json b/package-lock.json index e536756e5..c9700417c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15209,7 +15209,7 @@ "name": "cms-starter", "version": "0.0.0", "dependencies": { - "framer-plugin": "^3.1.0", + "framer-plugin": "^3.3.0", "react": "^18.3.1", "react-dom": "^18.3.1" }, @@ -15424,9 +15424,9 @@ } }, "starters/cms/node_modules/framer-plugin": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/framer-plugin/-/framer-plugin-3.1.0.tgz", - "integrity": "sha512-7nIsoj3pBGcT6kJuqeCTNq85Y2qM7qsINFRgXwcVepw68QKqEs8inIEOLO4utxUb2VjRV0zizPzFeYZus2bl/A==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/framer-plugin/-/framer-plugin-3.3.0.tgz", + "integrity": "sha512-8zrW63Oml0tUFNHoKjA55OJg2YyXCyeL9D5Y8lSZ334A45kOJOwdRJK731iGdtW/7PjctLRYa5IP/XQ3iGHEYw==", "peerDependencies": { "react": "^18.2.0", "react-dom": "^18.2.0" diff --git a/starters/cms/package.json b/starters/cms/package.json index 185ab4a2b..a2ce10845 100644 --- a/starters/cms/package.json +++ b/starters/cms/package.json @@ -14,7 +14,7 @@ "typecheck": "tsc" }, "dependencies": { - "framer-plugin": "^3.1.0", + "framer-plugin": "^3.3.0", "react": "^18.3.1", "react-dom": "^18.3.1" }, diff --git a/starters/cms/src/App.css b/starters/cms/src/App.css index 2c4e096f0..991d51e8d 100644 --- a/starters/cms/src/App.css +++ b/starters/cms/src/App.css @@ -24,8 +24,17 @@ form { top: 0; } -.field-input { +select { width: 100%; +} + +select:disabled, +input[type="text"]:disabled, +.ignored { + opacity: 0.5; +} + +.mapping select { flex-shrink: 1; } @@ -88,10 +97,6 @@ form { color: var(--framer-color-text-secondary); } -.setup select { - width: 100%; -} - .mapping { padding-bottom: 0; } @@ -130,10 +135,6 @@ form { gap: 8px; } -.mapping .source-field[aria-disabled="true"] { - opacity: 0.5; -} - .mapping .source-field:focus-visible { outline: none; box-shadow: inset 0 0 0 1px var(--framer-color-tint); @@ -147,14 +148,18 @@ form { box-shadow: none; } -[data-framer-theme=light] .mapping .source-field input[type="checkbox"]:not(:checked) { +[data-framer-theme="light"] .mapping .source-field input[type="checkbox"]:not(:checked) { background: #ccc; } -[data-framer-theme=dark] .mapping .source-field input[type="checkbox"]:not(:checked) { +[data-framer-theme="dark"] .mapping .source-field input[type="checkbox"]:not(:checked) { background: #666; } +.mapping input[type="text"] { + width: 100%; +} + .mapping footer { position: sticky; bottom: 0; @@ -178,3 +183,7 @@ form { background: linear-gradient(to bottom, transparent, var(--framer-color-bg)); pointer-events: none; } + +.mapping footer > button { + text-transform: capitalize; +} diff --git a/starters/cms/src/FieldMapping.tsx b/starters/cms/src/FieldMapping.tsx index 6a67237aa..cc5c49f45 100644 --- a/starters/cms/src/FieldMapping.tsx +++ b/starters/cms/src/FieldMapping.tsx @@ -1,42 +1,46 @@ -import { type EditableManagedCollectionField, framer, type ManagedCollection } from "framer-plugin" +import { type ManagedCollectionFieldInput, framer, type ManagedCollection } from "framer-plugin" import { useEffect, useState } from "react" import { type DataSource, dataSourceOptions, mergeFieldsWithExistingFields, syncCollection } from "./data" interface FieldMappingRowProps { - field: EditableManagedCollectionField + field: ManagedCollectionFieldInput originalFieldName: string | undefined - disabled: boolean + isIgnored: boolean onToggleDisabled: (fieldId: string) => void onNameChange: (fieldId: string, name: string) => void } -function FieldMappingRow({ field, originalFieldName, disabled, onToggleDisabled, onNameChange }: FieldMappingRowProps) { +function FieldMappingRow({ + field, + originalFieldName, + isIgnored, + onToggleDisabled, + onNameChange, +}: FieldMappingRowProps) { return ( <> + maps to onNameChange(field.id, event.target.value)} @@ -50,7 +54,7 @@ function FieldMappingRow({ field, originalFieldName, disabled, onToggleDisabled, ) } -const initialManagedCollectionFields: EditableManagedCollectionField[] = [] +const initialManagedCollectionFields: ManagedCollectionFieldInput[] = [] const initialFieldIds: ReadonlySet = new Set() interface FieldMappingProps { @@ -68,7 +72,7 @@ export function FieldMapping({ collection, dataSource, initialSlugFieldId }: Fie const [possibleSlugFields] = useState(() => dataSource.fields.filter(field => field.type === "string")) - const [selectedSlugField, setSelectedSlugField] = useState( + const [selectedSlugField, setSelectedSlugField] = useState( possibleSlugFields.find(field => field.id === initialSlugFieldId) ?? possibleSlugFields[0] ?? null ) @@ -204,7 +208,7 @@ export function FieldMapping({ collection, dataSource, initialSlugFieldId }: Fie key={`field-${field.id}`} field={field} originalFieldName={dataSource.fields.find(sourceField => sourceField.id === field.id)?.name} - disabled={ignoredFieldIds.has(field.id)} + isIgnored={ignoredFieldIds.has(field.id)} onToggleDisabled={toggleFieldDisabledState} onNameChange={changeFieldName} /> @@ -212,15 +216,9 @@ export function FieldMapping({ collection, dataSource, initialSlugFieldId }: Fie
-
-
diff --git a/starters/cms/src/SelectDataSource.tsx b/starters/cms/src/SelectDataSource.tsx index e0a2a5ca3..72d1382dd 100644 --- a/starters/cms/src/SelectDataSource.tsx +++ b/starters/cms/src/SelectDataSource.tsx @@ -33,6 +33,7 @@ export function SelectDataSource({ onSelectDataSource }: SelectDataSourceProps)
+ CMS Starter -
: "Next"} diff --git a/starters/cms/src/data.ts b/starters/cms/src/data.ts index 5c269bb9e..24daa29e2 100644 --- a/starters/cms/src/data.ts +++ b/starters/cms/src/data.ts @@ -1,5 +1,5 @@ import { - type EditableManagedCollectionField, + type ManagedCollectionFieldInput, type FieldDataInput, framer, type ManagedCollection, @@ -13,7 +13,7 @@ export const PLUGIN_KEYS = { export interface DataSource { id: string - fields: readonly EditableManagedCollectionField[] + fields: readonly ManagedCollectionFieldInput[] items: FieldDataInput[] } @@ -44,7 +44,7 @@ export async function getDataSource(dataSourceId: string, abortSignal?: AbortSig const dataSource = await dataSourceResponse.json() // Map your source fields to supported field types in Framer - const fields: EditableManagedCollectionField[] = [] + const fields: ManagedCollectionFieldInput[] = [] for (const field of dataSource.fields) { switch (field.type) { case "string": @@ -83,9 +83,9 @@ export async function getDataSource(dataSourceId: string, abortSignal?: AbortSig } export function mergeFieldsWithExistingFields( - sourceFields: readonly EditableManagedCollectionField[], - existingFields: readonly EditableManagedCollectionField[] -): EditableManagedCollectionField[] { + sourceFields: readonly ManagedCollectionFieldInput[], + existingFields: readonly ManagedCollectionFieldInput[] +): ManagedCollectionFieldInput[] { return sourceFields.map(sourceField => { const existingField = existingFields.find(existingField => existingField.id === sourceField.id) if (existingField) { @@ -98,8 +98,8 @@ export function mergeFieldsWithExistingFields( export async function syncCollection( collection: ManagedCollection, dataSource: DataSource, - fields: readonly EditableManagedCollectionField[], - slugField: EditableManagedCollectionField + fields: readonly ManagedCollectionFieldInput[], + slugField: ManagedCollectionFieldInput ) { const sanitizedFields = fields.map(field => ({ ...field,