Skip to content

Commit 8910b3a

Browse files
chore: update locked element to v4 design (#16607)
Updates `locked` element to v4 design. Co-authored-by: Patrik Kozak <35232443+PatrikKozak@users.noreply.github.com>
1 parent 8d0536f commit 8910b3a

6 files changed

Lines changed: 51 additions & 19 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@layer payload-default {
2+
.locked {
3+
position: relative;
4+
display: inline-flex;
5+
align-items: center;
6+
justify-content: center;
7+
pointer-events: all;
8+
color: var(--color-icon);
9+
border: 0;
10+
background: transparent;
11+
border-radius: var(--radius-medium);
12+
cursor: default;
13+
outline: var(--stroke-width-medium) solid transparent;
14+
outline-offset: calc(var(--stroke-width-medium) * -1);
15+
16+
&:hover {
17+
background: var(--color-bg-secondary);
18+
}
19+
20+
&:active {
21+
background: var(--color-bg-secondary-pressed);
22+
}
23+
24+
&:focus-visible {
25+
outline-color: var(--color-border-selected);
26+
}
27+
}
28+
}

packages/ui/src/elements/Locked/index.scss

Lines changed: 0 additions & 16 deletions
This file was deleted.

packages/ui/src/elements/Locked/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { LockIcon } from '../../icons/Lock/index.js'
77
import { useTranslation } from '../../providers/Translation/index.js'
88
import { isClientUserObject } from '../../utilities/isClientUserObject.js'
99
import { Tooltip } from '../Tooltip/index.js'
10-
import './index.scss'
10+
import './index.css'
1111

1212
const baseClass = 'locked'
1313

@@ -29,7 +29,7 @@ export const Locked: React.FC<{
2929
tabIndex={0}
3030
>
3131
<Tooltip
32-
alignCaret="left"
32+
alignCaret="center"
3333
className={`${baseClass}__tooltip`}
3434
position="top"
3535
show={hovered}

packages/ui/src/icons/Lock/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import './index.css'
44

55
const paths = {
66
16: 'M10.776 8H5.224l-.025.005A.25.25 0 0 0 5 8.25v3.5c0 .138.112.25.25.25h5.5a.25.25 0 0 0 .25-.25v-3.5a.25.25 0 0 0-.199-.245zM7 7H6V6a2 2 0 1 1 4 0v1zM5 6a3 3 0 0 1 6 0v1.025c.57.116 1 .62 1 1.225v3.5c0 .69-.56 1.25-1.25 1.25h-5.5C4.56 13 4 12.44 4 11.75v-3.5c0-.605.43-1.11 1-1.225z',
7-
24: 'M9 8a3 3 0 1 1 6 0v2H9zm-1 2V8a4 4 0 1 1 8 0v2h.125C17.16 10 18 10.84 18 11.875v5.25C18 18.16 17.16 19 16.125 19h-8.25A1.875 1.875 0 0 1 6 17.125v-5.25C6 10.839 6.84 10 7.875 10zm-1 1.875c0-.483.392-.875.875-.875h8.25c.483 0 .875.392.875.875v5.25a.875.875 0 0 1-.875.875h-8.25A.875.875 0 0 1 7 17.125z',
7+
24: 'M12 6C13.6569 6 15 7.34315 15 9V11H15.5C16.3284 11 17 11.6716 17 12.5V16.5C17 17.3284 16.3284 18 15.5 18H8.5C7.67157 18 7 17.3284 7 16.5V12.5C7 11.6716 7.67157 11 8.5 11H9V9C9 7.34315 10.3431 6 12 6ZM8.5 12C8.22386 12 8 12.2239 8 12.5V16.5C8 16.7761 8.22386 17 8.5 17H15.5C15.7761 17 16 16.7761 16 16.5V12.5C16 12.2239 15.7761 12 15.5 12H8.5ZM12 7C10.8954 7 10 7.89543 10 9V11H14V9C14 7.89543 13.1046 7 12 7Z',
88
}
99

1010
export const LockIcon: React.FC<{

test/v4/views/Components/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { IDLabelSection } from './sections/IDLabel.js'
1717
import { InputStepperSection } from './sections/InputStepper.js'
1818
import { LexicalIconsSection } from './sections/LexicalIcons.js'
1919
import { LoadingSection } from './sections/LoadingSection.js'
20+
import { LockedSection } from './sections/Locked.js'
2021
import { ModalSection } from './sections/ModalSection.js'
2122
import { NoListResultsSection } from './sections/NoListResults.js'
2223
import { PillSection } from './sections/Pill.js'
@@ -60,6 +61,7 @@ type ComponentId =
6061
| 'json-field'
6162
| 'lexical-icons'
6263
| 'loading-overlay'
64+
| 'locked'
6365
// Patterns
6466
| 'modal'
6567
| 'no-list-results'
@@ -99,6 +101,7 @@ const componentOptions: ComponentOption[] = [
99101
{ category: 'primitives', label: 'Input', value: 'input' },
100102
{ category: 'primitives', label: 'Input Stepper', value: 'input-stepper' },
101103
{ category: 'primitives', label: 'Lexical Icons', value: 'lexical-icons' },
104+
{ category: 'primitives', label: 'Locked', value: 'locked' },
102105
{ category: 'primitives', label: 'Pill', value: 'pill' },
103106
{ category: 'primitives', label: 'Popup', value: 'popup' },
104107
{ category: 'primitives', label: 'Radio', value: 'radio' },
@@ -239,6 +242,7 @@ export const ComponentsView: React.FC = () => {
239242
<CopyToClipboardSection selectedComponent="copy-to-clipboard" />
240243
)}
241244
{shouldShow('banner', 'primitives') && <BannerSection selectedComponent="banner" />}
245+
{shouldShow('locked', 'primitives') && <LockedSection selectedComponent="locked" />}
242246
{shouldShow('input-stepper', 'primitives') && (
243247
<InputStepperSection selectedComponent="input-stepper" />
244248
)}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use client'
2+
3+
import { Locked } from '@payloadcms/ui'
4+
import React from 'react'
5+
6+
import { Section, Variant } from '../shared.js'
7+
8+
export const LockedSection: React.FC<{ selectedComponent: string }> = ({ selectedComponent }) => {
9+
return (
10+
<Section id="locked" selectedComponent={selectedComponent} title="Locked">
11+
<Variant label="Default">
12+
<Locked user={{ id: '1', email: 'Another user' } as any} />
13+
</Variant>
14+
</Section>
15+
)
16+
}

0 commit comments

Comments
 (0)