Project-defined link styles, legal links from System Pages; audit catches content-keyed logic, Polish text in code, link fields in globals
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -2,11 +2,19 @@ import type { ArrayField, Field, GroupField } from 'payload'
|
||||
|
||||
import { rowLabel } from '../admin-ui/rowLabel.js'
|
||||
|
||||
/** The default styles. A project may use any names of its own — see `appearances`. */
|
||||
export type LinkAppearance = 'link' | 'primary' | 'secondary'
|
||||
|
||||
/** One style the editor may pick: a value (`'highlight'`) or `{ label, value }` for a friendlier panel label. */
|
||||
export type LinkAppearanceOption = { label: string; value: string } | string
|
||||
|
||||
export type BuildLinkFieldOptions = {
|
||||
/** Visual styles the editor may pick. `false` → no appearance select. Default all three. */
|
||||
appearances?: false | LinkAppearance[]
|
||||
/**
|
||||
* Visual styles the editor may pick — the project's own names, mapped to its
|
||||
* classes in Button.tsx / the menu: `['primary', 'secondary', { label: 'Highlighted', value: 'highlight' }]`.
|
||||
* `false` → no appearance select. Default primary / secondary / link.
|
||||
*/
|
||||
appearances?: false | readonly LinkAppearanceOption[]
|
||||
/** Hide the label — for links that wrap something (a whole card, an image). */
|
||||
disableLabel?: boolean
|
||||
/** Field name. Default 'link'. */
|
||||
@@ -100,11 +108,12 @@ export function buildLinkField({
|
||||
}
|
||||
|
||||
if (appearances && appearances.length) {
|
||||
const options = appearances.map((a) => (typeof a === 'string' ? { label: a, value: a } : a))
|
||||
fields.push({
|
||||
name: 'appearance',
|
||||
type: 'select',
|
||||
defaultValue: appearances[0],
|
||||
options: appearances.map((a) => ({ label: a, value: a })),
|
||||
defaultValue: options[0].value,
|
||||
options,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user