Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit 12a6f1e

Browse files
committed
chore: update demo
1 parent 98ed101 commit 12a6f1e

File tree

9 files changed

+528
-741
lines changed

9 files changed

+528
-741
lines changed

packages/core/dev-test/config.yml

Lines changed: 211 additions & 211 deletions
Large diffs are not rendered by default.

packages/core/dev-test/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
33
<head>
44
<meta charset="utf-8" />

packages/core/dev-test/index.js

Lines changed: 0 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -11,148 +11,6 @@ const PostPreview = ({ entry, widgetFor }) => {
1111
);
1212
};
1313

14-
const PostPreviewCard = ({ entry, hasLocalBackup, collection }) => {
15-
const theme = useTheme();
16-
const date = new Date(entry.data.date);
17-
18-
const month = date.getMonth() + 1;
19-
const day = date.getDate();
20-
21-
const imageField = useMemo(() => collection.fields.find(f => f.name === 'image'), [collection]);
22-
const image = useMediaAsset(entry.data.image, collection, imageField, entry);
23-
24-
const [label, color] = useMemo(() => {
25-
switch (entry.status) {
26-
case 'draft':
27-
return ['Draft', theme.info.main];
28-
case 'pending_review':
29-
return ['In Review', theme.warning.main];
30-
case 'pending_publish':
31-
return ['Ready', theme.success.main];
32-
default:
33-
return ['Published', theme.common.gray];
34-
}
35-
}, [entry.status]);
36-
37-
return h(
38-
'div',
39-
{ style: { width: '100%' } },
40-
h('div', {
41-
style: {
42-
width: '100%',
43-
borderTopLeftRadius: '8px',
44-
borderTopRightRadius: '8px',
45-
overflow: 'hidden',
46-
height: '140px',
47-
backgroundSize: 'cover',
48-
backgroundRepeat: 'no-repeat',
49-
backgroundPosition: 'center',
50-
objectFit: 'cover',
51-
backgroundImage: `url('${image}')`,
52-
},
53-
}),
54-
h(
55-
'div',
56-
{ style: { padding: '16px', width: '100%' } },
57-
h(
58-
'div',
59-
{
60-
style: {
61-
display: 'flex',
62-
width: '100%',
63-
justifyContent: 'space-between',
64-
alignItems: 'start',
65-
gap: '4px',
66-
color: theme.text.primary,
67-
},
68-
},
69-
h(
70-
'div',
71-
{
72-
style: {
73-
display: 'flex',
74-
flexDirection: 'column',
75-
alignItems: 'baseline',
76-
gap: '4px',
77-
},
78-
},
79-
h(
80-
'div',
81-
{
82-
style: {
83-
fontSize: '14px',
84-
fontWeight: 700,
85-
color: 'rgb(107, 114, 128)',
86-
lineHeight: '18px',
87-
},
88-
},
89-
entry.data.title,
90-
),
91-
h(
92-
'span',
93-
{ style: { fontSize: '14px' } },
94-
`${date.getFullYear()}-${month < 10 ? `0${month}` : month}-${
95-
day < 10 ? `0${day}` : day
96-
}`,
97-
),
98-
),
99-
h(
100-
'div',
101-
{
102-
style: {
103-
display: 'flex',
104-
alignItems: 'center',
105-
whiteSpace: 'no-wrap',
106-
gap: '8px',
107-
},
108-
},
109-
hasLocalBackup
110-
? h(
111-
'div',
112-
{
113-
style: {
114-
border: '2px solid rgb(147, 197, 253)',
115-
borderRadius: '50%',
116-
color: 'rgb(147, 197, 253)',
117-
height: '18px',
118-
width: '18px',
119-
fontWeight: 'bold',
120-
fontSize: '11px',
121-
display: 'flex',
122-
alignItems: 'center',
123-
justifyContent: 'center',
124-
textAlign: 'center',
125-
},
126-
title: 'Has local backup',
127-
},
128-
'i',
129-
)
130-
: null,
131-
h(
132-
'div',
133-
{
134-
style: {
135-
backgroundColor: color,
136-
color: 'white',
137-
border: 'none',
138-
padding: '2px 6px',
139-
textAlign: 'center',
140-
textDecoration: 'none',
141-
display: 'inline-block',
142-
cursor: 'pointer',
143-
borderRadius: '4px',
144-
fontSize: '14px',
145-
whiteSpace: 'nowrap'
146-
},
147-
},
148-
label,
149-
),
150-
),
151-
),
152-
),
153-
);
154-
};
155-
15614
const PostDateFieldPreview = ({ value }) => {
15715
const date = new Date(value);
15816

@@ -237,7 +95,6 @@ const CustomPage = () => {
23795
};
23896

23997
CMS.registerPreviewTemplate('posts', PostPreview);
240-
// CMS.registerPreviewCard('posts', PostPreviewCard, () => 240);
24198
CMS.registerFieldPreview('posts', 'date', PostDateFieldPreview);
24299
CMS.registerPreviewTemplate('general', GeneralPreview);
243100
CMS.registerPreviewTemplate('authors', AuthorsPreview);

packages/demo/.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist/
2+
bin/
3+
public/
4+
.cache/

packages/demo/.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"arrowParens": "avoid",
3+
"trailingComma": "all",
4+
"singleQuote": true,
5+
"printWidth": 100
6+
}

packages/demo/index.html

Lines changed: 103 additions & 99 deletions
Large diffs are not rendered by default.

packages/demo/public/config.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
backend:
22
name: test-repo
3-
site_url: 'https://staticcms.org/'
3+
site_url: 'https://example.com'
44
media_folder: assets/uploads
55
media_library:
66
folder_support: true
77
locale: en
8+
publish_mode: editorial_workflow
89
i18n:
910
# Required and can be one of multiple_folders, multiple_files or single_file
1011
# multiple_folders - persists files in `<folder>/<locale>/<slug>.<extension>`
@@ -70,7 +71,7 @@ collections:
7071
- label: Body
7172
name: body
7273
widget: markdown
73-
hint: Main content goes here.
74+
hint: '*Main* __content__ __*goes*__ [here](example.com).'
7475
- name: faq
7576
label: FAQ
7677
folder: _faqs
@@ -578,6 +579,7 @@ collections:
578579
- label: Type 2 Object
579580
name: type_2_object
580581
widget: object
582+
summary: "{{datetime | date('yyyy-MM-dd')}}"
581583
fields:
582584
- label: Number
583585
name: number
@@ -788,16 +790,16 @@ collections:
788790
- name: prefix
789791
label: With Prefix
790792
widget: number
791-
prefix: "$"
793+
prefix: '$'
792794
- name: suffix
793795
label: With Suffix
794796
widget: number
795-
suffix: "%"
797+
suffix: '%'
796798
- name: prefix_and_suffix
797799
label: With Prefix and Suffix
798800
widget: number
799-
prefix: "$"
800-
suffix: "%"
801+
prefix: '$'
802+
suffix: '%'
801803
- name: object
802804
label: Object
803805
file: _widgets/object.json
@@ -1078,16 +1080,16 @@ collections:
10781080
- name: prefix
10791081
label: With Prefix
10801082
widget: string
1081-
prefix: "$"
1083+
prefix: '$'
10821084
- name: suffix
10831085
label: With Suffix
10841086
widget: string
1085-
suffix: "%"
1087+
suffix: '%'
10861088
- name: prefix_and_suffix
10871089
label: With Prefix and Suffix
10881090
widget: string
1089-
prefix: "$"
1090-
suffix: "%"
1091+
prefix: '$'
1092+
suffix: '%'
10911093
- name: text
10921094
label: Text
10931095
file: _widgets/text.json

0 commit comments

Comments
 (0)