Skip to content

Commit 0ada1f8

Browse files
committed
Landing page implementation
1 parent e4b0b35 commit 0ada1f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+18934
-851
lines changed

README.md

Lines changed: 1 addition & 848 deletions
Large diffs are not rendered by default.

example/public/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
name="description"
1010
content="The next content manager"
1111
/>
12-
<link rel="apple-touch-icon" href="logo192.png" />
12+
13+
<link rel="icon" type="image/png" sizes="192x192" href="%PUBLIC_URL%/icon-192x192.png">
14+
<link rel="icon" type="image/png" sizes="32x32" href="%PUBLIC_URL%/favicon-32x32.png">
15+
<link rel="icon" type="image/png" sizes="96x96" href="%PUBLIC_URL%/favicon-96x96.png">
16+
<link rel="icon" type="image/png" sizes="16x16" href="%PUBLIC_URL%/favicon-16x16.png">
17+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/icon-192x192.png" />
1318
<!--
1419
manifest.json provides metadata used when your web app is installed on a
1520
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/

src/CMSAppProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ const makeTheme = (
205205
default: mode === "dark" ? "#424242" : "#f6f8f9"
206206
},
207207
primary: {
208-
main: primaryColor ? primaryColor : blue["800"]
208+
main: primaryColor ? primaryColor : "#0070f4"
209209
},
210210
secondary: {
211211
main: secondaryColor ? secondaryColor : pink["400"]

src/collection/fields/TableNumberInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function NumberTableInput(props: {
4444
useEffect(
4545
() => {
4646
if (!focused && propStringValue !== internalValue)
47-
setInternalValue(value ? value.toString(): null);
47+
setInternalValue(value !== undefined && value !== null ? value.toString(): null);
4848
},
4949
[value, focused]
5050
);

src/types_test.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// This file contains a minimum example based on current code
2+
// to see that the type checking in our schemas does not work
3+
interface EntitySchema<Key extends string = string, T extends any = any> {
4+
properties: Record<Key, Property<T>>;
5+
}
6+
7+
type Property<T = any> =
8+
T extends string ? StringProperty :
9+
T extends number ? NumberProperty : never;
10+
11+
12+
interface StringProperty {
13+
dataType: "string";
14+
}
15+
16+
interface NumberProperty {
17+
dataType: "number";
18+
}
19+
20+
function buildSchemaFrom<Type extends Partial<{ [P in Key]: T; }>,
21+
Key extends string = Extract<keyof Type, string>,
22+
T = any>(
23+
schema: EntitySchema<Key, T>
24+
): EntitySchema<Key, T> {
25+
return schema;
26+
}
27+
28+
type Product = {
29+
name: string,
30+
price: number,
31+
}
32+
33+
export const productSchema = buildSchemaFrom<Product>({
34+
properties: {
35+
name: {
36+
dataType: "string"
37+
},
38+
price: {
39+
dataType: "string", // THIS SHOULD FAIL
40+
},
41+
// missing: { // This fails if uncommented, which is expected
42+
// dataType: "string",
43+
// },
44+
}
45+
});

website/.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Dependencies
2+
/node_modules
3+
4+
# Production
5+
/build
6+
7+
# Generated files
8+
.docusaurus
9+
.cache-loader
10+
11+
# Misc
12+
.DS_Store
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*

website/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Website
2+
3+
This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator.
4+
5+
## Installation
6+
7+
```console
8+
yarn install
9+
```
10+
11+
## Local Development
12+
13+
```console
14+
yarn start
15+
```
16+
17+
This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server.
18+
19+
## Build
20+
21+
```console
22+
yarn build
23+
```
24+
25+
This command generates static content into the `build` directory and can be served using any static contents hosting service.
26+
27+
## Deployment
28+
29+
```console
30+
GIT_USER=<Your GitHub username> USE_SSH=true yarn deploy
31+
```
32+
33+
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

website/babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
3+
};

website/blog/2019-05-28-hola.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
slug: hola
3+
title: Hola
4+
author: Gao Wei
5+
author_title: Docusaurus Core Team
6+
author_url: https://github.com/wgao19
7+
author_image_url: https://avatars1.githubusercontent.com/u/2055384?v=4
8+
tags: [hola, docusaurus]
9+
---
10+
11+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
slug: hello-world
3+
title: Hello
4+
author: Endilie Yacop Sucipto
5+
author_title: Maintainer of Docusaurus
6+
author_url: https://github.com/endiliey
7+
author_image_url: https://avatars1.githubusercontent.com/u/17883920?s=460&v=4
8+
tags: [hello, docusaurus]
9+
---
10+
11+
Welcome to this blog. This blog is created with [**Docusaurus 2 alpha**](https://v2.docusaurus.io/).
12+
13+
<!--truncate-->
14+
15+
This is a test post.
16+
17+
A whole bunch of other information.

website/blog/2019-05-30-welcome.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
slug: welcome
3+
title: Welcome
4+
author: Yangshun Tay
5+
author_title: Front End Engineer @ Facebook
6+
author_url: https://github.com/yangshun
7+
author_image_url: https://avatars0.githubusercontent.com/u/1315101?s=400&v=4
8+
tags: [facebook, hello, docusaurus]
9+
---
10+
11+
Blog features are powered by the blog plugin. Simply add files to the `blog` directory. It supports tags as well!
12+
13+
Delete the whole directory if you don't want the blog features. As simple as that!

website/docs/collections.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
id: collections
3+
title: Collections
4+
sidebar_label: Collections
5+
---
6+
7+
8+
Once you have defined at least one entity schema, you can include it in a
9+
collection. You can find collection views as the first level of navigation in
10+
the main menu, or as subcollections inside other collections, following the
11+
Firestore data schema.
12+
13+
* `name` The plural name of the view. E.g. 'products'.
14+
15+
* `relativePath` Relative Firestore path of this view to its parent. If this
16+
view is in the root the path is equal to the absolute one. This path also
17+
determines the URL in FireCMS.
18+
19+
* `defaultSize` Default size of the rendered collection.
20+
21+
* `group` Optional field used to group top level navigation entries under a
22+
navigation view. If you set this value in a subcollection it has no effect.
23+
24+
* `description` Optional description of this view. You can use Markdown.
25+
26+
* `properties` Properties displayed in this collection. If this property is not
27+
set every property is displayed.
28+
29+
* `excludedProperties` Properties that should NOT get displayed in the
30+
collection view. All the other properties from the entity are displayed. It
31+
has no effect if the `properties` value is set.
32+
33+
* `filterableProperties` List of properties that include a filter widget.
34+
Defaults to none.
35+
36+
* `initialFilter` Initial filters applied to this collection. Consider that you
37+
can filter any property, but only those included in
38+
`filterableProperties` will include the corresponding filter widget. Defaults
39+
to none
40+
41+
* `initialSort` Default sort applied to this collection. It takes tuples in the
42+
shape `["property_name", "asc"]` or `["property_name", "desc"]`
43+
44+
* `extraActions` Builder for rendering additional components such as buttons in
45+
the collection toolbar. The builder takes an object with
46+
props `entityCollection` and `selectedEntities` if any are set by the end
47+
user.
48+
49+
* `pagination` If enabled, content is loaded in batches. If `false` all entities
50+
in the collection are loaded. You can specify a number to specify the
51+
pagination size (50 by default)
52+
Defaults to `true`
53+
54+
* `additionalColumns` You can add additional columns to the collection view by
55+
implementing an additional column delegate.
56+
57+
* `textSearchDelegate` If a text search delegate is supplied, a search bar is
58+
displayed on top.
59+
60+
* `permissions` You can specify an object with boolean permissions with the
61+
shape `{edit:boolean; create:boolean; delete:boolean}` to indicate the actions
62+
the user can perform. You can also pass a `PermissionsBuilder` to customize
63+
the permissions based on user or entity.
64+
65+
* `inlineEditing` Can the elements in this collection be edited inline in the
66+
collection view. If this flag is set to false but `permissions.edit` is `true`
67+
, entities can still be edited in the side panel.
68+
69+
* `exportable` Should the data in this collection view include an export button.
70+
You can also set an `ExportConfig` configuration object to customize
71+
the export and add additional values.
72+
Defaults to `true`
73+
74+
* `subcollections` Following the Firestore document and collection schema, you
75+
can add subcollections to your entity in the same way you define the root
76+
collections.
77+
78+
* `onEntityDelete` Hook called after the entity gets deleted in Firestore.
79+
80+
### Additional columns
81+
82+
If you would like to include a column that does not map directly to a property,
83+
you can use the `additionalColumns` field, providing a
84+
`AdditionalColumnDelegate`, which includes an id, a title, and a builder that
85+
receives the corresponding entity.
86+
87+
In the builder you can return any React Component.
88+
89+
If you would like to do some async computation, such as fetching a different
90+
entity, you can use the utility component `AsyncPreviewComponent` to show a
91+
loading indicator.
92+
93+
### Subcollections
94+
95+
Subcollections are collections of entities that are found under another entity.
96+
For example, you can have a collection named "translations" under the entity
97+
"Article". You just need to use the same format as for defining your collection
98+
using the field `subcollections`.
99+
100+
Subcollections are easily accessible from the side view while editing an entity.
101+
102+
### Filters
103+
104+
Filtering support is currently limited to string, number and boolean values,
105+
including enum types. If you want a property to be filterable, you can mark it
106+
as such in the entity schema.
107+
108+
Any comments related to this feature are welcome.
109+
110+
### Text search
111+
112+
Firestore does not support native text search, so we need to rely on external
113+
solutions. If you specify a `textSearchDelegate` to the collection view, you
114+
will see a search bar on top. The delegate is in charge of returning the
115+
matching ids, from the search string.
116+
117+
A delegate using AlgoliaSearch is included, where you need to specify your
118+
credentials and index. For this to work you need to set up an AlgoliaSearch
119+
account and manage the indexing of your documents. There is a full backend
120+
example included in the code, which indexes documents with Cloud Functions.
121+
122+
You can also implement your own `TextSearchDelegate`, and would love to hear how
123+
you come around this problem.
124+

website/docs/config_intro.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
id: cms_config
3+
title: CMS main config
4+
sidebar_label: Main config
5+
---
6+
7+
8+
The entry point for setting up a FireCMS app is the `CMSApp`, where you can
9+
define the following specs:
10+
11+
- `name` Name of the app, displayed as the main title and in the tab title.
12+
13+
- `navigation` Use this prop to specify the views that will be generated in the
14+
CMS. You will usually want to create a `Navigation` object that includes
15+
collection views where you specify the path and the schema. Additionally, you
16+
can add custom views to the root navigation. In you need to customize the
17+
navigation based on the logged user you can use a `NavigationBuilder`
18+
19+
- `logo` Logo to be displayed in the drawer of the CMS.
20+
21+
- `authentication` Do the users need to log in to access the CMS. You can
22+
specify an Authenticator function to discriminate which users can access the
23+
CMS or not. If not specified, authentication is enabled but no user
24+
restrictions apply.
25+
26+
- `signInOptions` List of sign in options that will be displayed in the login
27+
view if `authentication` is enabled. You can pass google providers strings,
28+
such as `firebase.auth.GoogleAuthProvider.PROVIDER_ID` or full configuration
29+
objects such as specified
30+
in https://firebase.google.com/docs/auth/web/firebaseui
31+
Defaults to Google sign in only.
32+
33+
- `allowSkipLogin` If authentication is enabled, allow the user to access the
34+
content without login.
35+
36+
- `firebaseConfig` Firebase configuration of the project. If you afe deploying
37+
the app to Firebase hosting, you don't need to specify this value.
38+
39+
- `onFirebaseInit` An optional callback after Firebase has been initialised.
40+
Useful for using the local emulator or retrieving the used configuration.
41+
42+
- `primaryColor` Primary color of the theme of the CMS.
43+
44+
- `secondaryColor` Primary color of the theme of the CMS.
45+
46+
- `fontFamily` Font family string. e.g. '"Roboto", "Helvetica", "Arial",
47+
sans-serif'.
48+
49+
- `toolbarExtraWidget` A component that gets rendered on the upper side of the
50+
main toolbar.
51+
52+
- `dateTimeFormat` Format of the dates in the CMS. Defaults to 'MMMM dd, yyyy,
53+
HH:mm:ss'
54+
55+
- `locale` Locale of the CMS, currently only affecting dates
56+
57+
- `schemaResolver` Used to override schemas based on the collection path and
58+
entityId. This resolver allows to override the schema for specific entities,
59+
or specific collections, app wide. This overrides schemas all through the app.
60+
You can also override schemas in place, when using `useSideEntityController`
61+
62+
63+
64+
#### More granular control
65+
66+
If you don't want to use FireCMS `CMSApp` as a full app but would like to
67+
integrate some of its components you may want to use the `CMSAppProvider`
68+
and `CMSMainView`
69+
components (used internally) directly.
70+
71+
This will allow you to initialise Firebase on your own and integrate the FireCMS
72+
components into your own app. Just place `CMSAppProvider` on top of the
73+
components that need to use the FireCMS hooks.
74+
75+
You can see an
76+
example [here](https://github.com/Camberi/firecms/blob/master/example/src/SimpleAppWithProvider.tsx)
77+

0 commit comments

Comments
 (0)