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

Commit

Permalink
chore: update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
KaneFreeman committed Nov 2, 2023
1 parent 98ed101 commit 12a6f1e
Show file tree
Hide file tree
Showing 9 changed files with 528 additions and 741 deletions.
422 changes: 211 additions & 211 deletions packages/core/dev-test/config.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/core/dev-test/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
143 changes: 0 additions & 143 deletions packages/core/dev-test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,148 +11,6 @@ const PostPreview = ({ entry, widgetFor }) => {
);
};

const PostPreviewCard = ({ entry, hasLocalBackup, collection }) => {
const theme = useTheme();
const date = new Date(entry.data.date);

const month = date.getMonth() + 1;
const day = date.getDate();

const imageField = useMemo(() => collection.fields.find(f => f.name === 'image'), [collection]);
const image = useMediaAsset(entry.data.image, collection, imageField, entry);

const [label, color] = useMemo(() => {
switch (entry.status) {
case 'draft':
return ['Draft', theme.info.main];
case 'pending_review':
return ['In Review', theme.warning.main];
case 'pending_publish':
return ['Ready', theme.success.main];
default:
return ['Published', theme.common.gray];
}
}, [entry.status]);

return h(
'div',
{ style: { width: '100%' } },
h('div', {
style: {
width: '100%',
borderTopLeftRadius: '8px',
borderTopRightRadius: '8px',
overflow: 'hidden',
height: '140px',
backgroundSize: 'cover',
backgroundRepeat: 'no-repeat',
backgroundPosition: 'center',
objectFit: 'cover',
backgroundImage: `url('${image}')`,
},
}),
h(
'div',
{ style: { padding: '16px', width: '100%' } },
h(
'div',
{
style: {
display: 'flex',
width: '100%',
justifyContent: 'space-between',
alignItems: 'start',
gap: '4px',
color: theme.text.primary,
},
},
h(
'div',
{
style: {
display: 'flex',
flexDirection: 'column',
alignItems: 'baseline',
gap: '4px',
},
},
h(
'div',
{
style: {
fontSize: '14px',
fontWeight: 700,
color: 'rgb(107, 114, 128)',
lineHeight: '18px',
},
},
entry.data.title,
),
h(
'span',
{ style: { fontSize: '14px' } },
`${date.getFullYear()}-${month < 10 ? `0${month}` : month}-${
day < 10 ? `0${day}` : day
}`,
),
),
h(
'div',
{
style: {
display: 'flex',
alignItems: 'center',
whiteSpace: 'no-wrap',
gap: '8px',
},
},
hasLocalBackup
? h(
'div',
{
style: {
border: '2px solid rgb(147, 197, 253)',
borderRadius: '50%',
color: 'rgb(147, 197, 253)',
height: '18px',
width: '18px',
fontWeight: 'bold',
fontSize: '11px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
textAlign: 'center',
},
title: 'Has local backup',
},
'i',
)
: null,
h(
'div',
{
style: {
backgroundColor: color,
color: 'white',
border: 'none',
padding: '2px 6px',
textAlign: 'center',
textDecoration: 'none',
display: 'inline-block',
cursor: 'pointer',
borderRadius: '4px',
fontSize: '14px',
whiteSpace: 'nowrap'
},
},
label,
),
),
),
),
);
};

const PostDateFieldPreview = ({ value }) => {
const date = new Date(value);

Expand Down Expand Up @@ -237,7 +95,6 @@ const CustomPage = () => {
};

CMS.registerPreviewTemplate('posts', PostPreview);
// CMS.registerPreviewCard('posts', PostPreviewCard, () => 240);
CMS.registerFieldPreview('posts', 'date', PostDateFieldPreview);
CMS.registerPreviewTemplate('general', GeneralPreview);
CMS.registerPreviewTemplate('authors', AuthorsPreview);
Expand Down
4 changes: 4 additions & 0 deletions packages/demo/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist/
bin/
public/
.cache/
6 changes: 6 additions & 0 deletions packages/demo/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"arrowParens": "avoid",
"trailingComma": "all",
"singleQuote": true,
"printWidth": 100
}
202 changes: 103 additions & 99 deletions packages/demo/index.html

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions packages/demo/public/config.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
backend:
name: test-repo
site_url: 'https://staticcms.org/'
site_url: 'https://example.com'
media_folder: assets/uploads
media_library:
folder_support: true
locale: en
publish_mode: editorial_workflow
i18n:
# Required and can be one of multiple_folders, multiple_files or single_file
# multiple_folders - persists files in `<folder>/<locale>/<slug>.<extension>`
Expand Down Expand Up @@ -70,7 +71,7 @@ collections:
- label: Body
name: body
widget: markdown
hint: Main content goes here.
hint: '*Main* __content__ __*goes*__ [here](example.com).'
- name: faq
label: FAQ
folder: _faqs
Expand Down Expand Up @@ -578,6 +579,7 @@ collections:
- label: Type 2 Object
name: type_2_object
widget: object
summary: "{{datetime | date('yyyy-MM-dd')}}"
fields:
- label: Number
name: number
Expand Down Expand Up @@ -788,16 +790,16 @@ collections:
- name: prefix
label: With Prefix
widget: number
prefix: "$"
prefix: '$'
- name: suffix
label: With Suffix
widget: number
suffix: "%"
suffix: '%'
- name: prefix_and_suffix
label: With Prefix and Suffix
widget: number
prefix: "$"
suffix: "%"
prefix: '$'
suffix: '%'
- name: object
label: Object
file: _widgets/object.json
Expand Down Expand Up @@ -1078,16 +1080,16 @@ collections:
- name: prefix
label: With Prefix
widget: string
prefix: "$"
prefix: '$'
- name: suffix
label: With Suffix
widget: string
suffix: "%"
suffix: '%'
- name: prefix_and_suffix
label: With Prefix and Suffix
widget: string
prefix: "$"
suffix: "%"
prefix: '$'
suffix: '%'
- name: text
label: Text
file: _widgets/text.json
Expand Down
Loading

0 comments on commit 12a6f1e

Please sign in to comment.