├── .firebaserc ├── public ├── favicon.ico ├── manifest.json ├── index.html └── images │ ├── react-prismic.svg │ └── broccoli-florets.svg ├── .babelrc ├── src ├── library │ ├── setup.js │ ├── GlobalHeader │ │ ├── styles.css │ │ └── index.js │ └── VegetableList │ │ ├── readme.md │ │ ├── shareIcon.js │ │ ├── styles.css │ │ └── index.js └── components │ ├── Prismic │ ├── context.js │ ├── readme.md │ └── index.js │ ├── QueryMissing │ ├── readme.md │ └── index.js │ ├── QuerySimilar │ ├── readme.md │ └── index.js │ ├── QueryHas │ ├── readme.md │ └── index.js │ ├── QueryLessThan │ ├── readme.md │ └── index.js │ ├── QueryGreaterThan │ ├── readme.md │ └── index.js │ ├── QueryAny │ ├── readme.md │ └── index.js │ ├── QueryYear │ ├── readme.md │ └── index.js │ ├── QueryMonth │ ├── readme.md │ └── index.js │ ├── QueryDayOfMonth │ ├── readme.md │ └── index.js │ ├── QueryMonthAfter │ ├── readme.md │ └── index.js │ ├── QueryHourAfter │ ├── readme.md │ └── index.js │ ├── QueryHourBefore │ ├── readme.md │ └── index.js │ ├── QueryDateAfter │ ├── readme.md │ └── index.js │ ├── QueryDayOfMonthAfter │ ├── readme.md │ └── index.js │ ├── QueryDayOfMonthBefore │ ├── readme.md │ └── index.js │ ├── QueryDayOfWeek │ ├── readme.md │ └── index.js │ ├── QueryHour │ ├── readme.md │ └── index.js │ ├── QueryMonthBefore │ ├── readme.md │ └── index.js │ ├── QueryDateBefore │ ├── readme.md │ └── index.js │ ├── QueryDayOfWeekAfter │ ├── readme.md │ └── index.js │ ├── QueryDayOfWeekBefore │ ├── readme.md │ └── index.js │ ├── QueryIn │ ├── readme.md │ └── index.js │ ├── QueryInRange │ ├── readme.md │ └── index.js │ ├── Query │ ├── resolve-multi-predicates.js │ ├── make-cancelable-promise.js │ ├── should-fetch.js │ └── index.js │ ├── QueryMulti │ ├── readme.md │ └── index.js │ ├── QueryAt │ ├── readme.md │ └── index.js │ ├── QueryDateBetween │ ├── readme.md │ └── index.js │ ├── QueryNot │ ├── readme.md │ └── index.js │ ├── index.js │ └── QueryFullText │ ├── readme.md │ └── index.js ├── firebase.json ├── docs ├── usage.md └── overview.md ├── .gitignore ├── .eslintrc.json ├── README.md ├── .circleci └── config.yml ├── package.json ├── styleguide.config.js └── .firebase └── hosting.c3R5bGVndWlkZQ.cache /.firebaserc: -------------------------------------------------------------------------------- 1 | { 2 | "projects": { 3 | "default": "react-prismic-cms" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reiniergs/react-prismic-cms/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets" : ["env", "react"], 3 | "plugins": ["transform-object-rest-spread"] 4 | } 5 | -------------------------------------------------------------------------------- /src/library/setup.js: -------------------------------------------------------------------------------- 1 | import GlobalHeader from './GlobalHeader'; 2 | 3 | global.GlobalHeader = GlobalHeader; 4 | -------------------------------------------------------------------------------- /src/components/Prismic/context.js: -------------------------------------------------------------------------------- 1 | import { createContext } from 'react'; 2 | 3 | export default createContext(); 4 | -------------------------------------------------------------------------------- /src/components/QueryMissing/readme.md: -------------------------------------------------------------------------------- 1 | vegetables: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QuerySimilar/readme.md: -------------------------------------------------------------------------------- 1 | Tomatoes: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryHas/readme.md: -------------------------------------------------------------------------------- 1 | fruits: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/Prismic/readme.md: -------------------------------------------------------------------------------- 1 | vegetables 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryLessThan/readme.md: -------------------------------------------------------------------------------- 1 | fruits less than $10: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryGreaterThan/readme.md: -------------------------------------------------------------------------------- 1 | Fruits greater than $8: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryAny/readme.md: -------------------------------------------------------------------------------- 1 | vegetables and fruit: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryYear/readme.md: -------------------------------------------------------------------------------- 1 | Publications of 2018: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryMonth/readme.md: -------------------------------------------------------------------------------- 1 | Publications of october: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryDayOfMonth/readme.md: -------------------------------------------------------------------------------- 1 | Publications of the 17th: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryMonthAfter/readme.md: -------------------------------------------------------------------------------- 1 | Publications after september: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryHourAfter/readme.md: -------------------------------------------------------------------------------- 1 | Publications made after 4:00 PM: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryHourBefore/readme.md: -------------------------------------------------------------------------------- 1 | Publications made before 1:00 AM: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryDateAfter/readme.md: -------------------------------------------------------------------------------- 1 | Publications after 2018-10-17 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryDayOfMonthAfter/readme.md: -------------------------------------------------------------------------------- 1 | Publications after 16th: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryDayOfMonthBefore/readme.md: -------------------------------------------------------------------------------- 1 | Publications before 16th: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryDayOfWeek/readme.md: -------------------------------------------------------------------------------- 1 | Publications of the wednesday 17th: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryHour/readme.md: -------------------------------------------------------------------------------- 1 | Publications made between 12:00 AM and 1:00 AM: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryMonthBefore/readme.md: -------------------------------------------------------------------------------- 1 | Publications before november: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryDateBefore/readme.md: -------------------------------------------------------------------------------- 1 | Publications before 2018-10-17: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryDayOfWeekAfter/readme.md: -------------------------------------------------------------------------------- 1 | Publications after tuesday 16th: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "hosting": { 3 | "public": "styleguide", 4 | "rewrites": [ 5 | { 6 | "source": "**", 7 | "destination": "/index.html" 8 | } 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/components/QueryDayOfWeekBefore/readme.md: -------------------------------------------------------------------------------- 1 | Publications before saturday: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryIn/readme.md: -------------------------------------------------------------------------------- 1 | Tomatoes, Cherries and Apples: 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/QueryInRange/readme.md: -------------------------------------------------------------------------------- 1 | fruits between $2 and $10: 2 | 3 | const value = { 4 | lowerLimit: 2, 5 | upperLimit: 10, 6 | }; 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/components/Query/resolve-multi-predicates.js: -------------------------------------------------------------------------------- 1 | import Prismic from 'prismic-javascript'; 2 | 3 | export default function resolveMultiPredicates(multiPredicates) { 4 | return multiPredicates.map((item) => { 5 | const { predicate, path, value } = item; 6 | return Prismic.Predicates[predicate](path, value); 7 | }); 8 | } 9 | -------------------------------------------------------------------------------- /src/components/QueryMulti/readme.md: -------------------------------------------------------------------------------- 1 | Only vegetables but not the green ones: 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/components/QueryAt/readme.md: -------------------------------------------------------------------------------- 1 | vegetables: 2 | 3 | 4 | 5 | 6 | 7 | red vegetables: 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/components/QueryDateBetween/readme.md: -------------------------------------------------------------------------------- 1 | Publications between 2018-10-17 and 2018-10-19: 2 | 3 | const value = { 4 | startDate: '2018-10-17', 5 | endDate: '2018-10-19', 6 | }; 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /src/components/QueryNot/readme.md: -------------------------------------------------------------------------------- 1 | not vegetables: 2 | 3 | 4 | 5 | 6 | 7 | not green vegetables: 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/usage.md: -------------------------------------------------------------------------------- 1 | ## There are several runnable examples in this Git repo, but here's one in CodeSandbox listing vegetables: 2 | 3 |
4 | 5 |
6 | -------------------------------------------------------------------------------- /src/library/GlobalHeader/styles.css: -------------------------------------------------------------------------------- 1 | .prismic-cms-card_header { 2 | display: flex; 3 | align-items: center; 4 | justify-content: space-between; 5 | background-color: #ffffff; 6 | border-radius: 14px 14px 0 0; 7 | border-bottom: solid 1px #e3e5ed; 8 | box-shadow: 0 1px 1px 0 #e3e5ed; 9 | color: #1ad1a3; 10 | font-size: 18px; 11 | height: 64px; 12 | padding: 0 24px; 13 | } 14 | -------------------------------------------------------------------------------- /src/library/VegetableList/readme.md: -------------------------------------------------------------------------------- 1 | VegetableList example: 2 | 3 | const response = { 4 | results: [{ 5 | id: 'vegetable-1', 6 | data: { 7 | name: [{ text: 'Brocolli' }], 8 | image: { url: 'public/images/broccoli-florets.svg' }, 9 | description: [{ text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.' }], 10 | } 11 | }] 12 | }; 13 | 14 | 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | .idea 3 | # dependencies 4 | /node_modules 5 | 6 | # testing 7 | /coverage 8 | 9 | # production 10 | /build 11 | components 12 | !src/components 13 | library 14 | !src/library 15 | styleguide 16 | 17 | # misc 18 | .DS_Store 19 | .env.local 20 | .env.development.local 21 | .env.test.local 22 | .env.production.local 23 | package-lock.json 24 | 25 | npm-debug.log* 26 | yarn-debug.log* 27 | yarn-error.log* 28 | -------------------------------------------------------------------------------- /src/components/Query/make-cancelable-promise.js: -------------------------------------------------------------------------------- 1 | export default function makeCancelablePromise(promise) { 2 | let hasCanceled = false; 3 | const rejectResponse = { 4 | isCanceled: true, 5 | }; 6 | 7 | const wrappedPromise = new Promise((resolve, reject) => { 8 | promise.then( 9 | val => (hasCanceled ? reject(rejectResponse) : resolve(val)), 10 | error => (hasCanceled ? reject(rejectResponse) : reject(error)), 11 | ); 12 | }); 13 | 14 | return { 15 | promise: wrappedPromise, 16 | cancel() { 17 | hasCanceled = true; 18 | }, 19 | }; 20 | } 21 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "airbnb", 3 | "plugins": [ 4 | "babel", 5 | "react", 6 | "jsx-a11y", 7 | "import" 8 | ], 9 | "rules": { 10 | "indent": [2, 4], 11 | "react/jsx-filename-extension": [2, { "extensions": [".js", ".jsx"] }], 12 | "react/jsx-indent": "off", 13 | "react/jsx-first-prop-new-line": "off", 14 | "react/jsx-indent-props": "off", 15 | "react/jsx-closing-bracket-location": "off", 16 | "react/forbid-prop-types": "off" 17 | }, 18 | "env": { 19 | "es6": true, 20 | "node": true, 21 | "browser": true 22 | }, 23 | "parser": "babel-eslint", 24 | "parserOptions": { 25 | "sourceType": "module" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/components/Query/should-fetch.js: -------------------------------------------------------------------------------- 1 | const PROPS = [ 2 | 'path', 3 | 'value', 4 | 'after', 5 | 'fetch', 6 | 'fetchLinks', 7 | 'orderings', 8 | 'page', 9 | 'pageSize', 10 | ]; 11 | 12 | function isPropAnArray(prevProp, currentProp) { 13 | return (Array.isArray(prevProp) && Array.isArray(currentProp)) || false; 14 | } 15 | 16 | function isNotEqual(prevProp, currentProp) { 17 | return prevProp.join('') !== currentProp.join(''); 18 | } 19 | 20 | export default function shouldFetch(prevProps, currentProps) { 21 | return PROPS.some((prop) => { 22 | if (isPropAnArray(prevProps[prop], currentProps[prop])) { 23 | return isNotEqual(prevProps[prop], currentProps[prop]); 24 | } 25 | return prevProps[prop] !== currentProps[prop]; 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /docs/overview.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ### Take the stress out of managing a website. By nature, content management systems support the separation of content and presentation. This is what you will accomplish with this React Library on top of Prismic.io 5 | 6 | ### react-prismic-cms is available as an npm package 7 | 8 | ## Advantages 9 | 10 | * Fetches the content through declarative components that allow you to focus only in the experience interface. 11 | * Platform agnostic (react & react native) 12 | * Reduces need to code from scratch 13 | 14 | ## A few use cases 15 | 16 | * Listing items by an specific criteria 17 | * Changing & hiding content without the need of new build. 18 | * Filtering content with tags 19 | * Content localization 20 | 21 | ## Interactive Examples 22 | 23 | Proper documentation based on interactive examples to help you understand the features of each component. 24 | -------------------------------------------------------------------------------- /src/library/GlobalHeader/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import classnames from 'classnames'; 4 | import Avatar from 'react-rainbow-components/components/Avatar'; 5 | import './styles.css'; 6 | 7 | export default function GlobalHeader(props) { 8 | const { 9 | className, 10 | children, 11 | style, 12 | title, 13 | } = props; 14 | 15 | const getContainerClassNames = () => classnames('prismic-cms-card_header', className); 16 | 17 | return ( 18 |
19 | 20 | {title} 21 | 22 |
23 | {children} 24 | 30 |
31 |
32 | ); 33 | } 34 | 35 | GlobalHeader.propTypes = { 36 | title: PropTypes.node, 37 | children: PropTypes.node, 38 | className: PropTypes.string, 39 | style: PropTypes.object, 40 | }; 41 | 42 | GlobalHeader.defaultProps = { 43 | title: null, 44 | children: null, 45 | className: undefined, 46 | style: undefined, 47 | }; 48 | -------------------------------------------------------------------------------- /src/library/VegetableList/shareIcon.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | 4 | const ShareIcon = (props) => { 5 | const { className } = props; 6 | return ( 7 | 8 | 9 | 10 | ); 11 | }; 12 | 13 | ShareIcon.propTypes = { 14 | className: PropTypes.string, 15 | }; 16 | 17 | ShareIcon.defaultProps = { 18 | className: undefined, 19 | }; 20 | 21 | export default ShareIcon; 22 | -------------------------------------------------------------------------------- /src/library/VegetableList/styles.css: -------------------------------------------------------------------------------- 1 | .prismic-cms-card_content { 2 | display: flex; 3 | flex-wrap: wrap; 4 | justify-content: space-around; 5 | padding: 32px 24px 0 24px; 6 | } 7 | 8 | .prismic-cms-card_content .prismic-cms-card-item { 9 | margin-bottom: 32px; 10 | } 11 | 12 | .prismic-cms-card-item { 13 | width: 250px; 14 | font-family: Lato; 15 | } 16 | 17 | .prismic-cms-card-item_img-container { 18 | display: flex; 19 | align-items: center; 20 | justify-content: center; 21 | height: 120px; 22 | } 23 | 24 | .prismic-cms-card-item_content { 25 | display: flex; 26 | flex-direction: column; 27 | align-items: center; 28 | } 29 | 30 | .prismic-cms-card-item_header { 31 | font-size: 20px; 32 | font-weight: 500; 33 | color: #061c3f; 34 | margin: 0; 35 | text-align: justify; 36 | align-self: flex-start; 37 | } 38 | 39 | .prismic-cms-card-item_description { 40 | font-size: 14px; 41 | font-weight: 300; 42 | text-align: justify; 43 | line-height: 1.5em; 44 | color: #576574; 45 | margin: 8px 0; 46 | align-self: flex-start; 47 | text-overflow: ellipsis; 48 | word-wrap: break-word; 49 | overflow: hidden; 50 | max-height: 3em; 51 | } 52 | 53 | .prismic-cms-card-item_button { 54 | border: solid 1px #1ad1a3; 55 | color: #1ad1a3; 56 | width: 90px; 57 | } 58 | 59 | .prismic-cms-card-item_button:hover, .prismic-cms-card-item_button:focus { 60 | border: solid 1px #1cb891; 61 | color: #1cb891; 62 | } 63 | -------------------------------------------------------------------------------- /src/components/Prismic/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Context from './context'; 4 | 5 | export default function Prismic(props) { 6 | const { 7 | repo, 8 | ref, 9 | lang, 10 | children, 11 | } = props; 12 | 13 | return ( 14 | 15 | {children} 16 | 17 | ); 18 | } 19 | 20 | Prismic.propTypes = { 21 | /** The prismic repository name. */ 22 | repo: PropTypes.string, 23 | /** The ref option defines which version of your content to query. 24 | * By default prismic will use the master ref 25 | * to retrieve the currently published documents. */ 26 | ref: PropTypes.string, 27 | /** Defines the language code for the results of your query. 28 | * For example "en-us" for American English. 29 | * If no lang is provided, then the query will default to 30 | * the master language of the repository. 31 | * You can also pass the wilcard value * to specify that you want to query 32 | * documents in all available languages. * */ 33 | lang: PropTypes.string, 34 | /** 35 | * This prop should not be visible in the documentation. 36 | * @ignore 37 | */ 38 | children: PropTypes.oneOfType([ 39 | PropTypes.arrayOf(PropTypes.node), 40 | PropTypes.object, 41 | ]), 42 | }; 43 | 44 | Prismic.defaultProps = { 45 | repo: undefined, 46 | ref: undefined, 47 | lang: undefined, 48 | children: null, 49 | }; 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | React Prismic CMS 3 |

4 | 5 | Set of declarative components to query content published in the headless CMS [prismic.io](https://prismic.io/) 6 | 7 | [![CircleCI](https://circleci.com/gh/reiniergs/react-prismic-cms.svg?style=svg)](https://circleci.com/gh/reiniergs/react-prismic-cms) 8 | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 9 | [![npm version](https://badge.fury.io/js/react-prismic-cms.svg)](https://badge.fury.io/js/react-prismic-cms) 10 | 11 | ## Installation 12 | 13 | ```bash 14 | $ yarn add react-prismic-cms 15 | ``` 16 | 17 | ## Usage 18 | 19 | ```jsx 20 | import React from "react"; 21 | import ReactDOM from "react-dom"; 22 | import Prismic from "react-prismic-cms/components/Prismic"; 23 | import QueryAt from "react-prismic-cms/components/QueryAt"; 24 | import Vegetables from "./vegetables"; 25 | import "./styles.css"; 26 | 27 | function App() { 28 | return ( 29 |
30 | 31 | 36 | 37 |
38 | ); 39 | } 40 | 41 | const rootElement = document.getElementById("root"); 42 | ReactDOM.render(, rootElement); 43 | ``` 44 | 45 | [![Edit 4x20k907n0](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/4x20k907n0) 46 | 47 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 22 | React App 23 | 24 | 25 | 28 |
29 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build_and_test: 4 | docker: 5 | # specify the version you desire here 6 | - image: circleci/node:9.10.0 7 | 8 | # Specify service dependencies here if necessary 9 | # CircleCI maintains a library of pre-built images 10 | # documented at https://circleci.com/docs/2.0/circleci-images/ 11 | # - image: circleci/mongo:3.4.4 12 | 13 | working_directory: ~/repo 14 | 15 | steps: 16 | - checkout 17 | 18 | # Download and cache dependencies 19 | - restore_cache: 20 | keys: 21 | - v1-dependencies-{{ checksum "yarn.lock" }} 22 | # fallback to using the latest cache if no exact match is found 23 | - v1-dependencies- 24 | 25 | - run: yarn install 26 | 27 | - save_cache: 28 | paths: 29 | - node_modules 30 | key: v1-dependencies-{{ checksum "yarn.lock" }} 31 | 32 | - run: yarn lint 33 | 34 | deploy_firebase: 35 | docker: 36 | - image: circleci/node:9.10.0 37 | 38 | working_directory: ~/repo 39 | 40 | steps: 41 | - checkout 42 | 43 | # Download and cache dependencies 44 | - restore_cache: 45 | keys: 46 | - v1-dependencies-{{ checksum "yarn.lock" }} 47 | # fallback to using the latest cache if no exact match is found 48 | - v1-dependencies- 49 | 50 | - run: yarn install 51 | - run: yarn deploy --token=$FIREBASE_TOKEN 52 | 53 | workflows: 54 | version: 2 55 | build_and_test: 56 | jobs: 57 | - build_and_test 58 | - deploy_firebase: 59 | requires: 60 | - build_and_test 61 | filters: 62 | branches: 63 | only: master 64 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-prismic-cms", 3 | "version": "0.3.1", 4 | "main": "components/index.js", 5 | "dependencies": { 6 | "classnames": "^2.2.6", 7 | "prismic-javascript": "^1.5.0", 8 | "prop-types": "^15.6.2", 9 | "react": "^16.5.2", 10 | "react-json-view": "^1.19.1", 11 | "react-rainbow-components": "^0.5.0" 12 | }, 13 | "devDependencies": { 14 | "babel-cli": "^6.26.0", 15 | "babel-plugin-transform-object-rest-spread": "^6.26.0", 16 | "babel-preset-env": "^1.7.0", 17 | "babel-preset-react": "^6.24.1", 18 | "eslint": "^5.7.0", 19 | "eslint-config-airbnb": "^17.1.0", 20 | "eslint-plugin-babel": "^5.3.0", 21 | "eslint-plugin-import": "^2.14.0", 22 | "eslint-plugin-jsx-a11y": "^6.1.2", 23 | "eslint-plugin-react": "^7.11.1", 24 | "firebase-tools": "^5.1.1", 25 | "pre-push": "^0.1.1", 26 | "react-dom": "^16.5.2", 27 | "react-rainbow-styleguide": "^1.1.0", 28 | "react-scripts": "2.0.4", 29 | "react-styleguidist": "^7.3.9" 30 | }, 31 | "scripts": { 32 | "start": "npx styleguidist server", 33 | "build": "npx styleguidist build", 34 | "build:components": "npx babel ./src --out-dir ./", 35 | "test": "react-scripts test", 36 | "lint": "eslint src", 37 | "eject": "react-scripts eject", 38 | "prepublishOnly": "yarn clean && yarn build:components", 39 | "clean": "rm -Rf components", 40 | "deploy": "yarn build && firebase deploy" 41 | }, 42 | "eslintConfig": { 43 | "extends": "react-app" 44 | }, 45 | "browserslist": [ 46 | ">0.2%", 47 | "not dead", 48 | "not ie <= 11", 49 | "not op_mini all" 50 | ], 51 | "license": "MIT", 52 | "pre-push": [ 53 | "lint" 54 | ] 55 | } 56 | -------------------------------------------------------------------------------- /src/components/index.js: -------------------------------------------------------------------------------- 1 | import Prismic from './Prismic'; 2 | import QueryAny from './QueryAny'; 3 | import QueryAt from './QueryAt'; 4 | import QueryDateAfter from './QueryDateAfter'; 5 | import QueryDateBefore from './QueryDateBefore'; 6 | import QueryDateBetween from './QueryDateBetween'; 7 | import QueryDayOfMonth from './QueryDayOfMonth'; 8 | import QueryDayOfMonthAfter from './QueryDayOfMonthAfter'; 9 | import QueryDayOfMonthBefore from './QueryDayOfMonthBefore'; 10 | import QueryDayOfWeek from './QueryDayOfWeek'; 11 | import QueryDayOfWeekAfter from './QueryDayOfWeekAfter'; 12 | import QueryDayOfWeekBefore from './QueryDayOfWeekBefore'; 13 | import QueryFullText from './QueryFullText'; 14 | import QueryGreaterThan from './QueryGreaterThan'; 15 | import QueryHas from './QueryHas'; 16 | import QueryHour from './QueryHour'; 17 | import QueryHourAfter from './QueryHourAfter'; 18 | import QueryHourBefore from './QueryHourBefore'; 19 | import QueryIn from './QueryIn'; 20 | import QueryInRange from './QueryInRange'; 21 | import QueryLessThan from './QueryLessThan'; 22 | import QueryMissing from './QueryMissing'; 23 | import QueryMonth from './QueryMonth'; 24 | import QueryMonthAfter from './QueryMonthAfter'; 25 | import QueryMonthBefore from './QueryMonthBefore'; 26 | import QueryMulti from './QueryMulti'; 27 | import QueryNot from './QueryNot'; 28 | import QuerySimilar from './QuerySimilar'; 29 | import QueryYear from './QueryYear'; 30 | 31 | export { 32 | Prismic, 33 | QueryAny, 34 | QueryAt, 35 | QueryDateAfter, 36 | QueryDateBefore, 37 | QueryDateBetween, 38 | QueryDayOfMonth, 39 | QueryDayOfMonthAfter, 40 | QueryDayOfMonthBefore, 41 | QueryDayOfWeek, 42 | QueryDayOfWeekAfter, 43 | QueryDayOfWeekBefore, 44 | QueryFullText, 45 | QueryGreaterThan, 46 | QueryHas, 47 | QueryHour, 48 | QueryHourAfter, 49 | QueryHourBefore, 50 | QueryIn, 51 | QueryInRange, 52 | QueryLessThan, 53 | QueryMissing, 54 | QueryMonth, 55 | QueryMonthAfter, 56 | QueryMonthBefore, 57 | QueryMulti, 58 | QueryNot, 59 | QuerySimilar, 60 | QueryYear, 61 | }; 62 | -------------------------------------------------------------------------------- /src/library/VegetableList/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import classnames from 'classnames'; 4 | import ButtonIcon from 'react-rainbow-components/components/ButtonIcon'; 5 | import Button from 'react-rainbow-components/components/Button'; 6 | import Card from 'react-rainbow-components/components/Card'; 7 | import ShareIcon from './shareIcon'; 8 | import './styles.css'; 9 | 10 | function CardItems({ results }) { 11 | return results.map(({ data, id }) => ( 12 | } 19 | /> 20 | )} 21 | footer={( 22 |
23 |

{data.name[0].text}

24 |

{data.description[0].text}

25 |
31 | )} 32 | > 33 |
34 | 35 |
36 |
37 | )); 38 | } 39 | 40 | export default function VegetableList(props) { 41 | const { className, style, response } = props; 42 | 43 | const getContainerClassNames = () => classnames('prismic-cms-card_content', className); 44 | 45 | if (response && Array.isArray(response.results)) { 46 | return ( 47 |
48 | 49 |
50 | ); 51 | } 52 | return null; 53 | } 54 | 55 | VegetableList.propTypes = { 56 | className: PropTypes.string, 57 | style: PropTypes.object, 58 | response: PropTypes.object, 59 | }; 60 | 61 | VegetableList.defaultProps = { 62 | className: undefined, 63 | style: undefined, 64 | response: null, 65 | }; 66 | -------------------------------------------------------------------------------- /src/components/QueryFullText/readme.md: -------------------------------------------------------------------------------- 1 | vegetables: 2 | 3 | const Input = require('react-rainbow-components/components/Input').default; 4 | 5 | const inputStyle = { 6 | maxWidth: 200, 7 | marginTop: 24, 8 | marginLeft: 48, 9 | }; 10 | 11 | class FullTextExample extends React.Component { 12 | constructor(props) { 13 | super(props); 14 | this.state = { 15 | value: '', 16 | } 17 | } 18 | 19 | render() { 20 | const { value } = this.state; 21 | 22 | return ( 23 |
24 | this.setState({ value: e.target.value })} /> 29 | 30 | 31 | 35 | 36 | 37 |
38 | ); 39 | } 40 | } 41 | 42 | 43 | 44 | 45 | fruits: 46 | 47 | const Input = require('react-rainbow-components/components/Input').default; 48 | 49 | const inputStyle = { 50 | maxWidth: 200, 51 | marginTop: 24, 52 | marginLeft: 48, 53 | }; 54 | 55 | class FullTextExample extends React.Component { 56 | constructor(props) { 57 | super(props); 58 | this.state = { 59 | value: '', 60 | } 61 | } 62 | 63 | render() { 64 | const { value } = this.state; 65 | 66 | return ( 67 |
68 | this.setState({ value: e.target.value })} /> 73 | 74 | 75 | 79 | 80 | 81 |
82 | ); 83 | } 84 | } 85 | 86 | 87 | -------------------------------------------------------------------------------- /styleguide.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | const path = require('path'); 3 | const withRainbowStyles = require('react-rainbow-styleguide'); 4 | const version = require('./package.json').version; 5 | 6 | module.exports = withRainbowStyles({ 7 | version, 8 | title: 'react-prismic-cms', 9 | ignore: ['**/__tests__/**', '/node_modules/**'], 10 | require: [ 11 | path.resolve(__dirname, 'src/library/setup.js'), 12 | ], 13 | skipComponentsWithoutExample: true, 14 | pagePerSection: true, 15 | assetsDir: 'public', 16 | ribbon: { url: 'https://github.com/reiniergs/react-prismic-cms' }, 17 | template: { 18 | favicon: 'https://react-prismic-cms.firebaseapp.com/favicon.ico', 19 | head: { 20 | meta: [ 21 | { 22 | name: 'robots', 23 | content: 'index,follow' 24 | }, 25 | { 26 | name: 'description', 27 | content: 'Set of declarative component to query content published in the headless CMS prismic.io' 28 | }, 29 | { 30 | name: 'keywords', 31 | content: 'react, prismic, cms, content, components, library' 32 | }, 33 | { 34 | property: 'og:title', 35 | content: 'React Prismic CMS' 36 | }, 37 | { 38 | property: 'og:description', 39 | content: 'Set of declarative component to query content published in the headless CMS prismic.io' 40 | }, 41 | { 42 | property: 'og:image', 43 | content: 'https://react-rainbow.firebaseapp.com/share-image.png' 44 | } 45 | ] 46 | }, 47 | }, 48 | sections: [ 49 | { 50 | name: 'Getting Started', 51 | sectionDepth: 1, 52 | content: 'docs/overview.md', 53 | sections: [ 54 | { 55 | name: 'Overview', 56 | content: 'docs/overview.md', 57 | }, 58 | { 59 | name: 'Usage', 60 | content: 'docs/usage.md', 61 | }, 62 | ], 63 | }, 64 | { 65 | name: 'Query Components', 66 | components: 'src/components/**/index.js', 67 | sectionDepth: 1, 68 | usageMode: 'expand', 69 | }, 70 | { 71 | name: 'Docs Components', 72 | components: 'src/library/**/index.js', 73 | sectionDepth: 1, 74 | usageMode: 'expand', 75 | }, 76 | ], 77 | }); 78 | -------------------------------------------------------------------------------- /src/components/QueryHas/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryHas checks whether a fragment has a value. Note that it will 7 | * restrict the results to the custom type implied in the path. 8 | */ 9 | export default function QueryHas(props) { 10 | return ; 11 | } 12 | 13 | QueryHas.propTypes = { 14 | /** Defines what the query will be looking for. The only path available is 15 | * 'my.{custom-type}.{field}', where {custom-type} is the API ID of the custom 16 | * type you want to query and {field} is the API ID of the specific field in 17 | * the custom type that you need. */ 18 | path: PropTypes.string.isRequired, 19 | /** The componet used to render the queried data. */ 20 | component: PropTypes.func, 21 | /** It will remove all the documents except for those after the specified document in the list. 22 | * By reversing the orderings in your query, you can use this same method to retrieve all 23 | * the documents before the specified document. */ 24 | after: PropTypes.string, 25 | /** It is used to make queries faster by only retrieving the specified field(s). */ 26 | fetch: PropTypes.oneOfType([ 27 | PropTypes.string, 28 | PropTypes.array, 29 | ]), 30 | /** It allows you to retrieve a specific content field from a linked document and 31 | * add it to the document response object. 32 | * This props needs to take the following format: 33 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 34 | fetchLinks: PropTypes.oneOfType([ 35 | PropTypes.string, 36 | PropTypes.array, 37 | ]), 38 | /** It will order the results by the specified field(s). 39 | * You can specify as many fields as you want. 40 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 41 | * Use "desc" next to the field name to instead order it from greatest 42 | * to lowest e.g('[my.product.price desc]'). 43 | * You can specify more than one field to order your results by. To do so, 44 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 45 | * It is also possible to order documents by their first or 46 | * last publication dates e.g('[document.first_publication_date]'). */ 47 | orderings: PropTypes.string, 48 | /** The page option defines the pagination for the result of your query. 49 | * This value defaults to "1", corresponding to the first page. */ 50 | page: PropTypes.number, 51 | /** The pageSize option defines the maximum number of documents that the API 52 | * will return for your query. This value defaults to 20, max is 100. */ 53 | pageSize: PropTypes.number, 54 | }; 55 | 56 | QueryHas.defaultProps = { 57 | component: undefined, 58 | after: undefined, 59 | fetch: undefined, 60 | fetchLinks: undefined, 61 | orderings: undefined, 62 | page: 1, 63 | pageSize: 20, 64 | }; 65 | -------------------------------------------------------------------------------- /src/components/QueryMissing/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryMissing checks if a fragment doesn't have a value. 7 | * Note that this component will restrict the results to the custom type implied in the path. 8 | */ 9 | export default function QueryMissing(props) { 10 | return ; 11 | } 12 | 13 | QueryMissing.propTypes = { 14 | /** Defines what the query will be looking for. The only path available is 15 | * 'my.{custom-type}.{field}', where {custom-type} is the API ID of the custom 16 | * type you want to query and {field} is the API ID of the specific field in 17 | * the custom type that you need. */ 18 | path: PropTypes.string.isRequired, 19 | /** The componet used to render the queried data. */ 20 | component: PropTypes.func, 21 | /** It will remove all the documents except for those after the specified document in the list. 22 | * By reversing the orderings in your query, you can use this same method to retrieve all 23 | * the documents before the specified document. */ 24 | after: PropTypes.string, 25 | /** It is used to make queries faster by only retrieving the specified field(s). */ 26 | fetch: PropTypes.oneOfType([ 27 | PropTypes.string, 28 | PropTypes.array, 29 | ]), 30 | /** It allows you to retrieve a specific content field from a linked document and 31 | * add it to the document response object. 32 | * This props needs to take the following format: 33 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 34 | fetchLinks: PropTypes.oneOfType([ 35 | PropTypes.string, 36 | PropTypes.array, 37 | ]), 38 | /** It will order the results by the specified field(s). 39 | * You can specify as many fields as you want. 40 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 41 | * Use "desc" next to the field name to instead order it from greatest 42 | * to lowest e.g('[my.product.price desc]'). 43 | * You can specify more than one field to order your results by. To do so, 44 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 45 | * It is also possible to order documents by their first or 46 | * last publication dates e.g('[document.first_publication_date]'). */ 47 | orderings: PropTypes.string, 48 | /** The page option defines the pagination for the result of your query. 49 | * This value defaults to "1", corresponding to the first page. */ 50 | page: PropTypes.number, 51 | /** The pageSize option defines the maximum number of documents that the API 52 | * will return for your query. This value defaults to 20, max is 100. */ 53 | pageSize: PropTypes.number, 54 | }; 55 | 56 | QueryMissing.defaultProps = { 57 | component: undefined, 58 | after: undefined, 59 | fetch: undefined, 60 | fetchLinks: undefined, 61 | orderings: undefined, 62 | page: 1, 63 | pageSize: 20, 64 | }; 65 | -------------------------------------------------------------------------------- /src/components/QuerySimilar/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QuerySimilar takes the ID of a document, and returns a 7 | * list of documents with similar content. This allows you to build an 8 | * automated content discovery feature (for example, a "Related posts" section). 9 | */ 10 | export default function QuerySimilar(props) { 11 | return ; 12 | } 13 | 14 | QuerySimilar.propTypes = { 15 | /** Defines what the query will be looking for. The only path available is 'document.id'. */ 16 | path: PropTypes.string.isRequired, 17 | /** The maximum number of documents that a term may appear in to still be considered relevant. 18 | * Accept single number value. */ 19 | value: PropTypes.number, 20 | /** The componet used to render the queried data. */ 21 | component: PropTypes.func, 22 | /** It will remove all the documents except for those after the specified document in the list. 23 | * By reversing the orderings in your query, you can use this same method to retrieve all 24 | * the documents before the specified document. */ 25 | after: PropTypes.string, 26 | /** It is used to make queries faster by only retrieving the specified field(s). */ 27 | fetch: PropTypes.oneOfType([ 28 | PropTypes.string, 29 | PropTypes.array, 30 | ]), 31 | /** It allows you to retrieve a specific content field from a linked document and 32 | * add it to the document response object. 33 | * This props needs to take the following format: 34 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 35 | fetchLinks: PropTypes.oneOfType([ 36 | PropTypes.string, 37 | PropTypes.array, 38 | ]), 39 | /** It will order the results by the specified field(s). 40 | * You can specify as many fields as you want. 41 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 42 | * Use "desc" next to the field name to instead order it from greatest 43 | * to lowest e.g('[my.product.price desc]'). 44 | * You can specify more than one field to order your results by. To do so, 45 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 46 | * It is also possible to order documents by their first or 47 | * last publication dates e.g('[document.first_publication_date]'). */ 48 | orderings: PropTypes.string, 49 | /** The page option defines the pagination for the result of your query. 50 | * This value defaults to "1", corresponding to the first page. */ 51 | page: PropTypes.number, 52 | /** The pageSize option defines the maximum number of documents that the API 53 | * will return for your query. This value defaults to 20, max is 100. */ 54 | pageSize: PropTypes.number, 55 | }; 56 | 57 | QuerySimilar.defaultProps = { 58 | value: 10, 59 | component: undefined, 60 | after: undefined, 61 | fetch: undefined, 62 | fetchLinks: undefined, 63 | orderings: undefined, 64 | page: 1, 65 | pageSize: 20, 66 | }; 67 | -------------------------------------------------------------------------------- /src/components/QueryLessThan/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryLessThan checks that the value in the number field is less than the 7 | * value passed. 8 | */ 9 | export default function QueryLessThan(props) { 10 | return ; 11 | } 12 | 13 | QueryLessThan.propTypes = { 14 | /** Defines what the query will be looking for. The only path available is 15 | * 'my.{custom-type}.{field}', where {custom-type} is the API ID of the custom 16 | * type you want to query and {field} is the API ID of the specific field in 17 | * the custom type that you need. */ 18 | path: PropTypes.string.isRequired, 19 | /** Defines the value that the query is looking for. Accept single number value. */ 20 | value: PropTypes.number, 21 | /** The componet used to render the queried data. */ 22 | component: PropTypes.func, 23 | /** It will remove all the documents except for those after the specified document in the list. 24 | * By reversing the orderings in your query, you can use this same method to retrieve all 25 | * the documents before the specified document. */ 26 | after: PropTypes.string, 27 | /** It is used to make queries faster by only retrieving the specified field(s). */ 28 | fetch: PropTypes.oneOfType([ 29 | PropTypes.string, 30 | PropTypes.array, 31 | ]), 32 | /** It allows you to retrieve a specific content field from a linked document and 33 | * add it to the document response object. 34 | * This props needs to take the following format: 35 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 36 | fetchLinks: PropTypes.oneOfType([ 37 | PropTypes.string, 38 | PropTypes.array, 39 | ]), 40 | /** It will order the results by the specified field(s). 41 | * You can specify as many fields as you want. 42 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 43 | * Use "desc" next to the field name to instead order it from greatest 44 | * to lowest e.g('[my.product.price desc]'). 45 | * You can specify more than one field to order your results by. To do so, 46 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 47 | * It is also possible to order documents by their first or 48 | * last publication dates e.g('[document.first_publication_date]'). */ 49 | orderings: PropTypes.string, 50 | /** The page option defines the pagination for the result of your query. 51 | * This value defaults to "1", corresponding to the first page. */ 52 | page: PropTypes.number, 53 | /** The pageSize option defines the maximum number of documents that the API 54 | * will return for your query. This value defaults to 20, max is 100. */ 55 | pageSize: PropTypes.number, 56 | }; 57 | 58 | QueryLessThan.defaultProps = { 59 | value: 0, 60 | component: undefined, 61 | after: undefined, 62 | fetch: undefined, 63 | fetchLinks: undefined, 64 | orderings: undefined, 65 | page: 1, 66 | pageSize: 20, 67 | }; 68 | -------------------------------------------------------------------------------- /src/components/QueryGreaterThan/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryGreaterThan checks that the value in the number field is greater than 7 | * the value passed. 8 | */ 9 | export default function QueryGreaterThan(props) { 10 | return ; 11 | } 12 | 13 | QueryGreaterThan.propTypes = { 14 | /** Defines what the query will be looking for. The only path available is 15 | * 'my.{custom-type}.{field}', where {custom-type} is the API ID of the custom 16 | * type you want to query and {field} is the API ID of the specific field in 17 | * the custom type that you need. */ 18 | path: PropTypes.string.isRequired, 19 | /** Defines the value that the query is looking for. Accept single number value. */ 20 | value: PropTypes.number, 21 | /** The componet used to render the queried data. */ 22 | component: PropTypes.func, 23 | /** It will remove all the documents except for those after the specified document in the list. 24 | * By reversing the orderings in your query, you can use this same method to retrieve all 25 | * the documents before the specified document. */ 26 | after: PropTypes.string, 27 | /** It is used to make queries faster by only retrieving the specified field(s). */ 28 | fetch: PropTypes.oneOfType([ 29 | PropTypes.string, 30 | PropTypes.array, 31 | ]), 32 | /** It allows you to retrieve a specific content field from a linked document and 33 | * add it to the document response object. 34 | * This props needs to take the following format: 35 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 36 | fetchLinks: PropTypes.oneOfType([ 37 | PropTypes.string, 38 | PropTypes.array, 39 | ]), 40 | /** It will order the results by the specified field(s). 41 | * You can specify as many fields as you want. 42 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 43 | * Use "desc" next to the field name to instead order it from greatest 44 | * to lowest e.g('[my.product.price desc]'). 45 | * You can specify more than one field to order your results by. To do so, 46 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 47 | * It is also possible to order documents by their first or 48 | * last publication dates e.g('[document.first_publication_date]'). */ 49 | orderings: PropTypes.string, 50 | /** The page option defines the pagination for the result of your query. 51 | * This value defaults to "1", corresponding to the first page. */ 52 | page: PropTypes.number, 53 | /** The pageSize option defines the maximum number of documents that the API 54 | * will return for your query. This value defaults to 20, max is 100. */ 55 | pageSize: PropTypes.number, 56 | }; 57 | 58 | QueryGreaterThan.defaultProps = { 59 | value: 0, 60 | component: undefined, 61 | after: undefined, 62 | fetch: undefined, 63 | fetchLinks: undefined, 64 | orderings: undefined, 65 | page: 1, 66 | pageSize: 20, 67 | }; 68 | -------------------------------------------------------------------------------- /src/components/QueryInRange/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryInRange checks that the value in the path is within the 7 | * two values passed. 8 | */ 9 | export default function QueryInRange(props) { 10 | return ; 11 | } 12 | 13 | QueryInRange.propTypes = { 14 | /** Defines what the query will be looking for. The only path available is 15 | * 'my.{custom-type}.{field}', where {custom-type} is the API ID of the custom 16 | * type you want to query and {field} is the API ID of the specific field in 17 | * the custom type that you need. */ 18 | path: PropTypes.string.isRequired, 19 | /** Defines the value that the query is looking for. Accept an object value with lowerLimit 20 | * and upperLimit keys. */ 21 | value: PropTypes.shape({ 22 | lowerLimit: PropTypes.number, 23 | upperLimit: PropTypes.number, 24 | }), 25 | /** The componet used to render the queried data. */ 26 | component: PropTypes.func, 27 | /** It will remove all the documents except for those after the specified document in the list. 28 | * By reversing the orderings in your query, you can use this same method to retrieve all 29 | * the documents before the specified document. */ 30 | after: PropTypes.string, 31 | /** It is used to make queries faster by only retrieving the specified field(s). */ 32 | fetch: PropTypes.oneOfType([ 33 | PropTypes.string, 34 | PropTypes.array, 35 | ]), 36 | /** It allows you to retrieve a specific content field from a linked document and 37 | * add it to the document response object. 38 | * This props needs to take the following format: 39 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 40 | fetchLinks: PropTypes.oneOfType([ 41 | PropTypes.string, 42 | PropTypes.array, 43 | ]), 44 | /** It will order the results by the specified field(s). 45 | * You can specify as many fields as you want. 46 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 47 | * Use "desc" next to the field name to instead order it from greatest 48 | * to lowest e.g('[my.product.price desc]'). 49 | * You can specify more than one field to order your results by. To do so, 50 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 51 | * It is also possible to order documents by their first or 52 | * last publication dates e.g('[document.first_publication_date]'). */ 53 | orderings: PropTypes.string, 54 | /** The page option defines the pagination for the result of your query. 55 | * This value defaults to "1", corresponding to the first page. */ 56 | page: PropTypes.number, 57 | /** The pageSize option defines the maximum number of documents that the API 58 | * will return for your query. This value defaults to 20, max is 100. */ 59 | pageSize: PropTypes.number, 60 | }; 61 | 62 | QueryInRange.defaultProps = { 63 | value: {}, 64 | component: undefined, 65 | after: undefined, 66 | fetch: undefined, 67 | fetchLinks: undefined, 68 | orderings: undefined, 69 | page: 1, 70 | pageSize: 20, 71 | }; 72 | -------------------------------------------------------------------------------- /src/components/QueryNot/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryNot checks that the path doesn't match the provided value exactly. 7 | */ 8 | export default function QueryNot(props) { 9 | return ; 10 | } 11 | 12 | QueryNot.propTypes = { 13 | /** Defines what the query will be looking for. The different paths available are: 14 | * 'document.type', 'document.id', 'document.tags', and 'my.{custom-type}.{field}'. 15 | * The last path is in the format 'my.{custom-type}.{field}' where {custom-type} is 16 | * the API ID of the custom type you want to query and {field} is the API ID of the 17 | * specific field in the custom type that you need. */ 18 | path: PropTypes.string.isRequired, 19 | /** Defines the value that the query is looking for. */ 20 | value: PropTypes.oneOfType([ 21 | PropTypes.number, 22 | PropTypes.string, 23 | PropTypes.array, 24 | ]), 25 | /** The componet used to render the queried data. */ 26 | component: PropTypes.func, 27 | /** It will remove all the documents except for those after the specified document in the list. 28 | * By reversing the orderings in your query, you can use this same method to retrieve all 29 | * the documents before the specified document. */ 30 | after: PropTypes.string, 31 | /** It is used to make queries faster by only retrieving the specified field(s). */ 32 | fetch: PropTypes.oneOfType([ 33 | PropTypes.string, 34 | PropTypes.array, 35 | ]), 36 | /** It allows you to retrieve a specific content field from a linked document and 37 | * add it to the document response object. 38 | * This props needs to take the following format: 39 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 40 | fetchLinks: PropTypes.oneOfType([ 41 | PropTypes.string, 42 | PropTypes.array, 43 | ]), 44 | /** It will order the results by the specified field(s). 45 | * You can specify as many fields as you want. 46 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 47 | * Use "desc" next to the field name to instead order it from greatest 48 | * to lowest e.g('[my.product.price desc]'). 49 | * You can specify more than one field to order your results by. To do so, 50 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 51 | * It is also possible to order documents by their first or 52 | * last publication dates e.g('[document.first_publication_date]'). */ 53 | orderings: PropTypes.string, 54 | /** The page option defines the pagination for the result of your query. 55 | * This value defaults to "1", corresponding to the first page. */ 56 | page: PropTypes.number, 57 | /** The pageSize option defines the maximum number of documents that the API 58 | * will return for your query. This value defaults to 20, max is 100. */ 59 | pageSize: PropTypes.number, 60 | }; 61 | 62 | QueryNot.defaultProps = { 63 | value: '', 64 | component: undefined, 65 | after: undefined, 66 | fetch: undefined, 67 | fetchLinks: undefined, 68 | orderings: undefined, 69 | page: 1, 70 | pageSize: 20, 71 | }; 72 | -------------------------------------------------------------------------------- /src/components/QueryYear/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryYear checks that the value in the path occurs in the year 7 | * value passed. 8 | */ 9 | export default function QueryYear(props) { 10 | return ; 11 | } 12 | 13 | QueryYear.propTypes = { 14 | /** Defines what the query will be looking for. The different paths available are: 15 | * 'document.first_publication_date', 'document.last_publication_date' and 16 | * 'my.{custom-type}.{field}'. The last path is in the format 'my.{custom-type}.{field}' 17 | * where {custom-type} is the API ID of the custom type you want to query and {field} 18 | * is the API ID of the specific field in the custom type that you need. */ 19 | path: PropTypes.string.isRequired, 20 | /** Defines the value that the query is looking for. It is a number representing 21 | * the year. */ 22 | value: PropTypes.number, 23 | /** The componet used to render the queried data. */ 24 | component: PropTypes.func, 25 | /** It will remove all the documents except for those after the specified document in the list. 26 | * By reversing the orderings in your query, you can use this same method to retrieve all 27 | * the documents before the specified document. */ 28 | after: PropTypes.string, 29 | /** It is used to make queries faster by only retrieving the specified field(s). */ 30 | fetch: PropTypes.oneOfType([ 31 | PropTypes.string, 32 | PropTypes.array, 33 | ]), 34 | /** It allows you to retrieve a specific content field from a linked document and 35 | * add it to the document response object. 36 | * This props needs to take the following format: 37 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 38 | fetchLinks: PropTypes.oneOfType([ 39 | PropTypes.string, 40 | PropTypes.array, 41 | ]), 42 | /** It will order the results by the specified field(s). 43 | * You can specify as many fields as you want. 44 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 45 | * Use "desc" next to the field name to instead order it from greatest 46 | * to lowest e.g('[my.product.price desc]'). 47 | * You can specify more than one field to order your results by. To do so, 48 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 49 | * It is also possible to order documents by their first or 50 | * last publication dates e.g('[document.first_publication_date]'). */ 51 | orderings: PropTypes.string, 52 | /** The page option defines the pagination for the result of your query. 53 | * This value defaults to "1", corresponding to the first page. */ 54 | page: PropTypes.number, 55 | /** The pageSize option defines the maximum number of documents that the API 56 | * will return for your query. This value defaults to 20, max is 100. */ 57 | pageSize: PropTypes.number, 58 | }; 59 | 60 | QueryYear.defaultProps = { 61 | value: new Date().getFullYear(), 62 | component: undefined, 63 | after: undefined, 64 | fetch: undefined, 65 | fetchLinks: undefined, 66 | orderings: undefined, 67 | page: 1, 68 | pageSize: 20, 69 | }; 70 | -------------------------------------------------------------------------------- /src/components/QueryAny/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryAny takes an array of values. It works exactly the same 7 | * way as the QueryAt component, but checks whether the fragment matches 8 | * any of the values in the array. 9 | */ 10 | export default function QueryAny(props) { 11 | return ; 12 | } 13 | 14 | QueryAny.propTypes = { 15 | /** Defines what the query will be looking for. The different paths available are: 16 | * 'document.type', 'document.id', 'document.tags', and 'my.{custom-type}.{field}'. 17 | * The last path is in the format 'my.{custom-type}.{field}' where {custom-type} is 18 | * the API ID of the custom type you want to query and {field} is the API ID of the 19 | * specific field in the custom type that you need. */ 20 | path: PropTypes.string.isRequired, 21 | /** Defines the value that the query is looking for. Accept an array of values. */ 22 | value: PropTypes.array, 23 | /** The componet used to render the queried data. */ 24 | component: PropTypes.func, 25 | /** It will remove all the documents except for those after the specified document in the list. 26 | * By reversing the orderings in your query, you can use this same method to retrieve all 27 | * the documents before the specified document. */ 28 | after: PropTypes.string, 29 | /** It is used to make queries faster by only retrieving the specified field(s). */ 30 | fetch: PropTypes.oneOfType([ 31 | PropTypes.string, 32 | PropTypes.array, 33 | ]), 34 | /** It allows you to retrieve a specific content field from a linked document and 35 | * add it to the document response object. 36 | * This props needs to take the following format: 37 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 38 | fetchLinks: PropTypes.oneOfType([ 39 | PropTypes.string, 40 | PropTypes.array, 41 | ]), 42 | /** It will order the results by the specified field(s). 43 | * You can specify as many fields as you want. 44 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 45 | * Use "desc" next to the field name to instead order it from greatest 46 | * to lowest e.g('[my.product.price desc]'). 47 | * You can specify more than one field to order your results by. To do so, 48 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 49 | * It is also possible to order documents by their first or 50 | * last publication dates e.g('[document.first_publication_date]'). */ 51 | orderings: PropTypes.string, 52 | /** The page option defines the pagination for the result of your query. 53 | * This value defaults to "1", corresponding to the first page. */ 54 | page: PropTypes.number, 55 | /** The pageSize option defines the maximum number of documents that the API 56 | * will return for your query. This value defaults to 20, max is 100. */ 57 | pageSize: PropTypes.number, 58 | }; 59 | 60 | QueryAny.defaultProps = { 61 | value: [], 62 | component: undefined, 63 | after: undefined, 64 | fetch: undefined, 65 | fetchLinks: undefined, 66 | orderings: undefined, 67 | page: 1, 68 | pageSize: 20, 69 | }; 70 | -------------------------------------------------------------------------------- /src/components/QueryDayOfMonth/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryDayOfMonth checks that the value in the path 7 | * is equal to the day of the month passed. 8 | */ 9 | export default function QueryDayOfMonth(props) { 10 | return ; 11 | } 12 | 13 | QueryDayOfMonth.propTypes = { 14 | /** Defines what the query will be looking for. The different paths available are: 15 | * 'document.first_publication_date', 'document.last_publication_date' and 16 | * 'my.{custom-type}.{field}'. The last path is in the format 'my.{custom-type}.{field}' 17 | * where {custom-type} is the API ID of the custom type you want to query and {field} 18 | * is the API ID of the specific field in the custom type that you need. */ 19 | path: PropTypes.string.isRequired, 20 | /** Defines the value that the query is looking for. It is a number representing 21 | * the day of the month. */ 22 | value: PropTypes.number, 23 | /** The componet used to render the queried data. */ 24 | component: PropTypes.func, 25 | /** It will remove all the documents except for those after the specified document in the list. 26 | * By reversing the orderings in your query, you can use this same method to retrieve all 27 | * the documents before the specified document. */ 28 | after: PropTypes.string, 29 | /** It is used to make queries faster by only retrieving the specified field(s). */ 30 | fetch: PropTypes.oneOfType([ 31 | PropTypes.string, 32 | PropTypes.array, 33 | ]), 34 | /** It allows you to retrieve a specific content field from a linked document and 35 | * add it to the document response object. 36 | * This props needs to take the following format: 37 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 38 | fetchLinks: PropTypes.oneOfType([ 39 | PropTypes.string, 40 | PropTypes.array, 41 | ]), 42 | /** It will order the results by the specified field(s). 43 | * You can specify as many fields as you want. 44 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 45 | * Use "desc" next to the field name to instead order it from greatest 46 | * to lowest e.g('[my.product.price desc]'). 47 | * You can specify more than one field to order your results by. To do so, 48 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 49 | * It is also possible to order documents by their first or 50 | * last publication dates e.g('[document.first_publication_date]'). */ 51 | orderings: PropTypes.string, 52 | /** The page option defines the pagination for the result of your query. 53 | * This value defaults to "1", corresponding to the first page. */ 54 | page: PropTypes.number, 55 | /** The pageSize option defines the maximum number of documents that the API 56 | * will return for your query. This value defaults to 20, max is 100. */ 57 | pageSize: PropTypes.number, 58 | }; 59 | 60 | QueryDayOfMonth.defaultProps = { 61 | value: 1, 62 | component: undefined, 63 | after: undefined, 64 | fetch: undefined, 65 | fetchLinks: undefined, 66 | orderings: undefined, 67 | page: 1, 68 | pageSize: 20, 69 | }; 70 | -------------------------------------------------------------------------------- /src/components/QueryHourBefore/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryHourBefore checks that the value in the path occurs before the hour 7 | * value passed. 8 | */ 9 | export default function QueryHourBefore(props) { 10 | return ; 11 | } 12 | 13 | QueryHourBefore.propTypes = { 14 | /** Defines what the query will be looking for. The different paths available are: 15 | * 'document.first_publication_date', 'document.last_publication_date' and 16 | * 'my.{custom-type}.{field}'. The last path is in the format 'my.{custom-type}.{field}' 17 | * where {custom-type} is the API ID of the custom type you want to query and {field} 18 | * is the API ID of the specific field in the custom type that you need. */ 19 | path: PropTypes.string.isRequired, 20 | /** Defines the value that the query is looking for. It is a number representing 21 | * the hour between 0 and 23. */ 22 | value: PropTypes.number, 23 | /** The componet used to render the queried data. */ 24 | component: PropTypes.func, 25 | /** It will remove all the documents except for those after the specified document in the list. 26 | * By reversing the orderings in your query, you can use this same method to retrieve all 27 | * the documents before the specified document. */ 28 | after: PropTypes.string, 29 | /** It is used to make queries faster by only retrieving the specified field(s). */ 30 | fetch: PropTypes.oneOfType([ 31 | PropTypes.string, 32 | PropTypes.array, 33 | ]), 34 | /** It allows you to retrieve a specific content field from a linked document and 35 | * add it to the document response object. 36 | * This props needs to take the following format: 37 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 38 | fetchLinks: PropTypes.oneOfType([ 39 | PropTypes.string, 40 | PropTypes.array, 41 | ]), 42 | /** It will order the results by the specified field(s). 43 | * You can specify as many fields as you want. 44 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 45 | * Use "desc" next to the field name to instead order it from greatest 46 | * to lowest e.g('[my.product.price desc]'). 47 | * You can specify more than one field to order your results by. To do so, 48 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 49 | * It is also possible to order documents by their first or 50 | * last publication dates e.g('[document.first_publication_date]'). */ 51 | orderings: PropTypes.string, 52 | /** The page option defines the pagination for the result of your query. 53 | * This value defaults to "1", corresponding to the first page. */ 54 | page: PropTypes.number, 55 | /** The pageSize option defines the maximum number of documents that the API 56 | * will return for your query. This value defaults to 20, max is 100. */ 57 | pageSize: PropTypes.number, 58 | }; 59 | 60 | QueryHourBefore.defaultProps = { 61 | value: 0, 62 | component: undefined, 63 | after: undefined, 64 | fetch: undefined, 65 | fetchLinks: undefined, 66 | orderings: undefined, 67 | page: 1, 68 | pageSize: 20, 69 | }; 70 | -------------------------------------------------------------------------------- /src/components/QueryIn/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryIn is used specifically to retrieve an array of documents by their IDs or UIDs. 7 | * This component is much more efficient at this than the QueryAny. 8 | * This returns the documents in the same order as the passed array. 9 | */ 10 | export default function QueryIn(props) { 11 | return ; 12 | } 13 | 14 | QueryIn.propTypes = { 15 | /** Defines what the query will be looking for. The different paths available are: 16 | * 'document.id' and 'my.{custom-type}.{field}'. 17 | * The last path is in the format 'my.{custom-type}.{field}' where {custom-type} is 18 | * the API ID of the custom type you want to query and {field} is the API ID of the 19 | * specific field in the custom type that you need. */ 20 | path: PropTypes.string.isRequired, 21 | /** Defines the value that the query is looking for. Accept an array of values. */ 22 | value: PropTypes.array, 23 | /** The componet used to render the queried data. */ 24 | component: PropTypes.func, 25 | /** It will remove all the documents except for those after the specified document in the list. 26 | * By reversing the orderings in your query, you can use this same method to retrieve all 27 | * the documents before the specified document. */ 28 | after: PropTypes.string, 29 | /** It is used to make queries faster by only retrieving the specified field(s). */ 30 | fetch: PropTypes.oneOfType([ 31 | PropTypes.string, 32 | PropTypes.array, 33 | ]), 34 | /** It allows you to retrieve a specific content field from a linked document and 35 | * add it to the document response object. 36 | * This props needs to take the following format: 37 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 38 | fetchLinks: PropTypes.oneOfType([ 39 | PropTypes.string, 40 | PropTypes.array, 41 | ]), 42 | /** It will order the results by the specified field(s). 43 | * You can specify as many fields as you want. 44 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 45 | * Use "desc" next to the field name to instead order it from greatest 46 | * to lowest e.g('[my.product.price desc]'). 47 | * You can specify more than one field to order your results by. To do so, 48 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 49 | * It is also possible to order documents by their first or 50 | * last publication dates e.g('[document.first_publication_date]'). */ 51 | orderings: PropTypes.string, 52 | /** The page option defines the pagination for the result of your query. 53 | * This value defaults to "1", corresponding to the first page. */ 54 | page: PropTypes.number, 55 | /** The pageSize option defines the maximum number of documents that the API 56 | * will return for your query. This value defaults to 20, max is 100. */ 57 | pageSize: PropTypes.number, 58 | }; 59 | 60 | QueryIn.defaultProps = { 61 | value: [], 62 | component: undefined, 63 | after: undefined, 64 | fetch: undefined, 65 | fetchLinks: undefined, 66 | orderings: undefined, 67 | page: 1, 68 | pageSize: 20, 69 | }; 70 | -------------------------------------------------------------------------------- /src/components/QueryDayOfMonthAfter/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryDayOfMonthAfter checks that the value in the path 7 | * is after the day of the month passed. 8 | */ 9 | export default function QueryDayOfMonthAfter(props) { 10 | return ; 11 | } 12 | 13 | QueryDayOfMonthAfter.propTypes = { 14 | /** Defines what the query will be looking for. The different paths available are: 15 | * 'document.first_publication_date', 'document.last_publication_date' and 16 | * 'my.{custom-type}.{field}'. The last path is in the format 'my.{custom-type}.{field}' 17 | * where {custom-type} is the API ID of the custom type you want to query and {field} 18 | * is the API ID of the specific field in the custom type that you need. */ 19 | path: PropTypes.string.isRequired, 20 | /** Defines the value that the query is looking for. It is a number representing 21 | * the day of the month. */ 22 | value: PropTypes.number, 23 | /** The componet used to render the queried data. */ 24 | component: PropTypes.func, 25 | /** It will remove all the documents except for those after the specified document in the list. 26 | * By reversing the orderings in your query, you can use this same method to retrieve all 27 | * the documents before the specified document. */ 28 | after: PropTypes.string, 29 | /** It is used to make queries faster by only retrieving the specified field(s). */ 30 | fetch: PropTypes.oneOfType([ 31 | PropTypes.string, 32 | PropTypes.array, 33 | ]), 34 | /** It allows you to retrieve a specific content field from a linked document and 35 | * add it to the document response object. 36 | * This props needs to take the following format: 37 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 38 | fetchLinks: PropTypes.oneOfType([ 39 | PropTypes.string, 40 | PropTypes.array, 41 | ]), 42 | /** It will order the results by the specified field(s). 43 | * You can specify as many fields as you want. 44 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 45 | * Use "desc" next to the field name to instead order it from greatest 46 | * to lowest e.g('[my.product.price desc]'). 47 | * You can specify more than one field to order your results by. To do so, 48 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 49 | * It is also possible to order documents by their first or 50 | * last publication dates e.g('[document.first_publication_date]'). */ 51 | orderings: PropTypes.string, 52 | /** The page option defines the pagination for the result of your query. 53 | * This value defaults to "1", corresponding to the first page. */ 54 | page: PropTypes.number, 55 | /** The pageSize option defines the maximum number of documents that the API 56 | * will return for your query. This value defaults to 20, max is 100. */ 57 | pageSize: PropTypes.number, 58 | }; 59 | 60 | QueryDayOfMonthAfter.defaultProps = { 61 | value: 1, 62 | component: undefined, 63 | after: undefined, 64 | fetch: undefined, 65 | fetchLinks: undefined, 66 | orderings: undefined, 67 | page: 1, 68 | pageSize: 20, 69 | }; 70 | -------------------------------------------------------------------------------- /src/components/QueryDayOfMonthBefore/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryDayOfMonthBefore checks that the value in the path 7 | * is before the day of the month passed. 8 | */ 9 | export default function QueryDayOfMonthBefore(props) { 10 | return ; 11 | } 12 | 13 | QueryDayOfMonthBefore.propTypes = { 14 | /** Defines what the query will be looking for. The different paths available are: 15 | * 'document.first_publication_date', 'document.last_publication_date' and 16 | * 'my.{custom-type}.{field}'. The last path is in the format 'my.{custom-type}.{field}' 17 | * where {custom-type} is the API ID of the custom type you want to query and {field} 18 | * is the API ID of the specific field in the custom type that you need. */ 19 | path: PropTypes.string.isRequired, 20 | /** Defines the value that the query is looking for. It is a number representing 21 | * the day of the month. */ 22 | value: PropTypes.number, 23 | /** The componet used to render the queried data. */ 24 | component: PropTypes.func, 25 | /** It will remove all the documents except for those after the specified document in the list. 26 | * By reversing the orderings in your query, you can use this same method to retrieve all 27 | * the documents before the specified document. */ 28 | after: PropTypes.string, 29 | /** It is used to make queries faster by only retrieving the specified field(s). */ 30 | fetch: PropTypes.oneOfType([ 31 | PropTypes.string, 32 | PropTypes.array, 33 | ]), 34 | /** It allows you to retrieve a specific content field from a linked document and 35 | * add it to the document response object. 36 | * This props needs to take the following format: 37 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 38 | fetchLinks: PropTypes.oneOfType([ 39 | PropTypes.string, 40 | PropTypes.array, 41 | ]), 42 | /** It will order the results by the specified field(s). 43 | * You can specify as many fields as you want. 44 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 45 | * Use "desc" next to the field name to instead order it from greatest 46 | * to lowest e.g('[my.product.price desc]'). 47 | * You can specify more than one field to order your results by. To do so, 48 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 49 | * It is also possible to order documents by their first or 50 | * last publication dates e.g('[document.first_publication_date]'). */ 51 | orderings: PropTypes.string, 52 | /** The page option defines the pagination for the result of your query. 53 | * This value defaults to "1", corresponding to the first page. */ 54 | page: PropTypes.number, 55 | /** The pageSize option defines the maximum number of documents that the API 56 | * will return for your query. This value defaults to 20, max is 100. */ 57 | pageSize: PropTypes.number, 58 | }; 59 | 60 | QueryDayOfMonthBefore.defaultProps = { 61 | value: 1, 62 | component: undefined, 63 | after: undefined, 64 | fetch: undefined, 65 | fetchLinks: undefined, 66 | orderings: undefined, 67 | page: 1, 68 | pageSize: 20, 69 | }; 70 | -------------------------------------------------------------------------------- /src/components/QueryHourAfter/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryHourAfter checks that the value in the path occurs after 7 | * the hour value passed. This uses the 24 hour system, 8 | * starting at 0 and going through 23. 9 | */ 10 | export default function QueryHourAfter(props) { 11 | return ; 12 | } 13 | 14 | QueryHourAfter.propTypes = { 15 | /** Defines what the query will be looking for. The different paths available are: 16 | * 'document.first_publication_date', 'document.last_publication_date' and 17 | * 'my.{custom-type}.{field}'. The last path is in the format 'my.{custom-type}.{field}' 18 | * where {custom-type} is the API ID of the custom type you want to query and {field} 19 | * is the API ID of the specific field in the custom type that you need. */ 20 | path: PropTypes.string.isRequired, 21 | /** Defines the value that the query is looking for. It is a number representing 22 | * the hour between 0 and 23. */ 23 | value: PropTypes.number, 24 | /** The componet used to render the queried data. */ 25 | component: PropTypes.func, 26 | /** It will remove all the documents except for those after the specified document in the list. 27 | * By reversing the orderings in your query, you can use this same method to retrieve all 28 | * the documents before the specified document. */ 29 | after: PropTypes.string, 30 | /** It is used to make queries faster by only retrieving the specified field(s). */ 31 | fetch: PropTypes.oneOfType([ 32 | PropTypes.string, 33 | PropTypes.array, 34 | ]), 35 | /** It allows you to retrieve a specific content field from a linked document and 36 | * add it to the document response object. 37 | * This props needs to take the following format: 38 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 39 | fetchLinks: PropTypes.oneOfType([ 40 | PropTypes.string, 41 | PropTypes.array, 42 | ]), 43 | /** It will order the results by the specified field(s). 44 | * You can specify as many fields as you want. 45 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 46 | * Use "desc" next to the field name to instead order it from greatest 47 | * to lowest e.g('[my.product.price desc]'). 48 | * You can specify more than one field to order your results by. To do so, 49 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 50 | * It is also possible to order documents by their first or 51 | * last publication dates e.g('[document.first_publication_date]'). */ 52 | orderings: PropTypes.string, 53 | /** The page option defines the pagination for the result of your query. 54 | * This value defaults to "1", corresponding to the first page. */ 55 | page: PropTypes.number, 56 | /** The pageSize option defines the maximum number of documents that the API 57 | * will return for your query. This value defaults to 20, max is 100. */ 58 | pageSize: PropTypes.number, 59 | }; 60 | 61 | QueryHourAfter.defaultProps = { 62 | value: 0, 63 | component: undefined, 64 | after: undefined, 65 | fetch: undefined, 66 | fetchLinks: undefined, 67 | orderings: undefined, 68 | page: 1, 69 | pageSize: 20, 70 | }; 71 | -------------------------------------------------------------------------------- /src/components/QueryMonth/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryMonth checks that the value in the path occurs in the 7 | * month value passed. 8 | */ 9 | export default function QueryMonth(props) { 10 | return ; 11 | } 12 | 13 | QueryMonth.propTypes = { 14 | /** Defines what the query will be looking for. The different paths available are: 15 | * 'document.first_publication_date', 'document.last_publication_date' and 16 | * 'my.{custom-type}.{field}'. The last path is in the format 'my.{custom-type}.{field}' 17 | * where {custom-type} is the API ID of the custom type you want to query and {field} 18 | * is the API ID of the specific field in the custom type that you need. */ 19 | path: PropTypes.string.isRequired, 20 | /** Defines the value that the query is looking for. It is a number or string representing 21 | * the month. e.g('january', 'jan', or 1) */ 22 | value: PropTypes.oneOfType([ 23 | PropTypes.number, 24 | PropTypes.string, 25 | ]), 26 | /** The componet used to render the queried data. */ 27 | component: PropTypes.func, 28 | /** It will remove all the documents except for those after the specified document in the list. 29 | * By reversing the orderings in your query, you can use this same method to retrieve all 30 | * the documents before the specified document. */ 31 | after: PropTypes.string, 32 | /** It is used to make queries faster by only retrieving the specified field(s). */ 33 | fetch: PropTypes.oneOfType([ 34 | PropTypes.string, 35 | PropTypes.array, 36 | ]), 37 | /** It allows you to retrieve a specific content field from a linked document and 38 | * add it to the document response object. 39 | * This props needs to take the following format: 40 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 41 | fetchLinks: PropTypes.oneOfType([ 42 | PropTypes.string, 43 | PropTypes.array, 44 | ]), 45 | /** It will order the results by the specified field(s). 46 | * You can specify as many fields as you want. 47 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 48 | * Use "desc" next to the field name to instead order it from greatest 49 | * to lowest e.g('[my.product.price desc]'). 50 | * You can specify more than one field to order your results by. To do so, 51 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 52 | * It is also possible to order documents by their first or 53 | * last publication dates e.g('[document.first_publication_date]'). */ 54 | orderings: PropTypes.string, 55 | /** The page option defines the pagination for the result of your query. 56 | * This value defaults to "1", corresponding to the first page. */ 57 | page: PropTypes.number, 58 | /** The pageSize option defines the maximum number of documents that the API 59 | * will return for your query. This value defaults to 20, max is 100. */ 60 | pageSize: PropTypes.number, 61 | }; 62 | 63 | QueryMonth.defaultProps = { 64 | value: 1, 65 | component: undefined, 66 | after: undefined, 67 | fetch: undefined, 68 | fetchLinks: undefined, 69 | orderings: undefined, 70 | page: 1, 71 | pageSize: 20, 72 | }; 73 | -------------------------------------------------------------------------------- /src/components/QueryHour/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryHour checks that the value in the path occurs within the 7 | * hour value passed.This uses the 24 hour system, starting 8 | * at 0 and going through 23. All date field values are automatically given an hour of 0. 9 | */ 10 | export default function QueryHour(props) { 11 | return ; 12 | } 13 | 14 | QueryHour.propTypes = { 15 | /** Defines what the query will be looking for. The different paths available are: 16 | * 'document.first_publication_date', 'document.last_publication_date' and 17 | * 'my.{custom-type}.{field}'. The last path is in the format 'my.{custom-type}.{field}' 18 | * where {custom-type} is the API ID of the custom type you want to query and {field} 19 | * is the API ID of the specific field in the custom type that you need. */ 20 | path: PropTypes.string.isRequired, 21 | /** Defines the value that the query is looking for. It is a number representing 22 | * the hour between 0 and 23. */ 23 | value: PropTypes.number, 24 | /** The componet used to render the queried data. */ 25 | component: PropTypes.func, 26 | /** It will remove all the documents except for those after the specified document in the list. 27 | * By reversing the orderings in your query, you can use this same method to retrieve all 28 | * the documents before the specified document. */ 29 | after: PropTypes.string, 30 | /** It is used to make queries faster by only retrieving the specified field(s). */ 31 | fetch: PropTypes.oneOfType([ 32 | PropTypes.string, 33 | PropTypes.array, 34 | ]), 35 | /** It allows you to retrieve a specific content field from a linked document and 36 | * add it to the document response object. 37 | * This props needs to take the following format: 38 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 39 | fetchLinks: PropTypes.oneOfType([ 40 | PropTypes.string, 41 | PropTypes.array, 42 | ]), 43 | /** It will order the results by the specified field(s). 44 | * You can specify as many fields as you want. 45 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 46 | * Use "desc" next to the field name to instead order it from greatest 47 | * to lowest e.g('[my.product.price desc]'). 48 | * You can specify more than one field to order your results by. To do so, 49 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 50 | * It is also possible to order documents by their first or 51 | * last publication dates e.g('[document.first_publication_date]'). */ 52 | orderings: PropTypes.string, 53 | /** The page option defines the pagination for the result of your query. 54 | * This value defaults to "1", corresponding to the first page. */ 55 | page: PropTypes.number, 56 | /** The pageSize option defines the maximum number of documents that the API 57 | * will return for your query. This value defaults to 20, max is 100. */ 58 | pageSize: PropTypes.number, 59 | }; 60 | 61 | QueryHour.defaultProps = { 62 | value: 0, 63 | component: undefined, 64 | after: undefined, 65 | fetch: undefined, 66 | fetchLinks: undefined, 67 | orderings: undefined, 68 | page: 1, 69 | pageSize: 20, 70 | }; 71 | -------------------------------------------------------------------------------- /src/components/QueryDayOfWeek/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryDayOfWeek checks that the value in the path 7 | * is equal to the day of the week passed. 8 | */ 9 | export default function QueryDayOfWeek(props) { 10 | return ; 11 | } 12 | 13 | QueryDayOfWeek.propTypes = { 14 | /** Defines what the query will be looking for. The different paths available are: 15 | * 'document.first_publication_date', 'document.last_publication_date' and 16 | * 'my.{custom-type}.{field}'. The last path is in the format 'my.{custom-type}.{field}' 17 | * where {custom-type} is the API ID of the custom type you want to query and {field} 18 | * is the API ID of the specific field in the custom type that you need. */ 19 | path: PropTypes.string.isRequired, 20 | /** Defines the value that the query is looking for. It is a number or string representing 21 | * the day of the week. e.g('monday', 'mon', or 1) */ 22 | value: PropTypes.oneOfType([ 23 | PropTypes.number, 24 | PropTypes.string, 25 | ]), 26 | /** The componet used to render the queried data. */ 27 | component: PropTypes.func, 28 | /** It will remove all the documents except for those after the specified document in the list. 29 | * By reversing the orderings in your query, you can use this same method to retrieve all 30 | * the documents before the specified document. */ 31 | after: PropTypes.string, 32 | /** It is used to make queries faster by only retrieving the specified field(s). */ 33 | fetch: PropTypes.oneOfType([ 34 | PropTypes.string, 35 | PropTypes.array, 36 | ]), 37 | /** It allows you to retrieve a specific content field from a linked document and 38 | * add it to the document response object. 39 | * This props needs to take the following format: 40 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 41 | fetchLinks: PropTypes.oneOfType([ 42 | PropTypes.string, 43 | PropTypes.array, 44 | ]), 45 | /** It will order the results by the specified field(s). 46 | * You can specify as many fields as you want. 47 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 48 | * Use "desc" next to the field name to instead order it from greatest 49 | * to lowest e.g('[my.product.price desc]'). 50 | * You can specify more than one field to order your results by. To do so, 51 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 52 | * It is also possible to order documents by their first or 53 | * last publication dates e.g('[document.first_publication_date]'). */ 54 | orderings: PropTypes.string, 55 | /** The page option defines the pagination for the result of your query. 56 | * This value defaults to "1", corresponding to the first page. */ 57 | page: PropTypes.number, 58 | /** The pageSize option defines the maximum number of documents that the API 59 | * will return for your query. This value defaults to 20, max is 100. */ 60 | pageSize: PropTypes.number, 61 | }; 62 | 63 | QueryDayOfWeek.defaultProps = { 64 | value: 1, 65 | component: undefined, 66 | after: undefined, 67 | fetch: undefined, 68 | fetchLinks: undefined, 69 | orderings: undefined, 70 | page: 1, 71 | pageSize: 20, 72 | }; 73 | -------------------------------------------------------------------------------- /src/components/QueryMonthAfter/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryMonthAfter checks that the value in the path occurs in any month after 7 | * the value passed. 8 | */ 9 | export default function QueryMonthAfter(props) { 10 | return ; 11 | } 12 | 13 | QueryMonthAfter.propTypes = { 14 | /** Defines what the query will be looking for. The different paths available are: 15 | * 'document.first_publication_date', 'document.last_publication_date' and 16 | * 'my.{custom-type}.{field}'. The last path is in the format 'my.{custom-type}.{field}' 17 | * where {custom-type} is the API ID of the custom type you want to query and {field} 18 | * is the API ID of the specific field in the custom type that you need. */ 19 | path: PropTypes.string.isRequired, 20 | /** Defines the value that the query is looking for. It is a number or string representing 21 | * the month. e.g('january', 'jan', or 1) */ 22 | value: PropTypes.oneOfType([ 23 | PropTypes.number, 24 | PropTypes.string, 25 | ]), 26 | /** The componet used to render the queried data. */ 27 | component: PropTypes.func, 28 | /** It will remove all the documents except for those after the specified document in the list. 29 | * By reversing the orderings in your query, you can use this same method to retrieve all 30 | * the documents before the specified document. */ 31 | after: PropTypes.string, 32 | /** It is used to make queries faster by only retrieving the specified field(s). */ 33 | fetch: PropTypes.oneOfType([ 34 | PropTypes.string, 35 | PropTypes.array, 36 | ]), 37 | /** It allows you to retrieve a specific content field from a linked document and 38 | * add it to the document response object. 39 | * This props needs to take the following format: 40 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 41 | fetchLinks: PropTypes.oneOfType([ 42 | PropTypes.string, 43 | PropTypes.array, 44 | ]), 45 | /** It will order the results by the specified field(s). 46 | * You can specify as many fields as you want. 47 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 48 | * Use "desc" next to the field name to instead order it from greatest 49 | * to lowest e.g('[my.product.price desc]'). 50 | * You can specify more than one field to order your results by. To do so, 51 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 52 | * It is also possible to order documents by their first or 53 | * last publication dates e.g('[document.first_publication_date]'). */ 54 | orderings: PropTypes.string, 55 | /** The page option defines the pagination for the result of your query. 56 | * This value defaults to "1", corresponding to the first page. */ 57 | page: PropTypes.number, 58 | /** The pageSize option defines the maximum number of documents that the API 59 | * will return for your query. This value defaults to 20, max is 100. */ 60 | pageSize: PropTypes.number, 61 | }; 62 | 63 | QueryMonthAfter.defaultProps = { 64 | value: 1, 65 | component: undefined, 66 | after: undefined, 67 | fetch: undefined, 68 | fetchLinks: undefined, 69 | orderings: undefined, 70 | page: 1, 71 | pageSize: 20, 72 | }; 73 | -------------------------------------------------------------------------------- /src/components/QueryMonthBefore/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryMonthBefore checks that the value in the path occurs in any month 7 | * before the value passed. 8 | */ 9 | export default function QueryMonthBefore(props) { 10 | return ; 11 | } 12 | 13 | QueryMonthBefore.propTypes = { 14 | /** Defines what the query will be looking for. The different paths available are: 15 | * 'document.first_publication_date', 'document.last_publication_date' and 16 | * 'my.{custom-type}.{field}'. The last path is in the format 'my.{custom-type}.{field}' 17 | * where {custom-type} is the API ID of the custom type you want to query and {field} 18 | * is the API ID of the specific field in the custom type that you need. */ 19 | path: PropTypes.string.isRequired, 20 | /** Defines the value that the query is looking for. It is a number or string representing 21 | * the month. e.g('january', 'jan', or 1) */ 22 | value: PropTypes.oneOfType([ 23 | PropTypes.number, 24 | PropTypes.string, 25 | ]), 26 | /** The componet used to render the queried data. */ 27 | component: PropTypes.func, 28 | /** It will remove all the documents except for those after the specified document in the list. 29 | * By reversing the orderings in your query, you can use this same method to retrieve all 30 | * the documents before the specified document. */ 31 | after: PropTypes.string, 32 | /** It is used to make queries faster by only retrieving the specified field(s). */ 33 | fetch: PropTypes.oneOfType([ 34 | PropTypes.string, 35 | PropTypes.array, 36 | ]), 37 | /** It allows you to retrieve a specific content field from a linked document and 38 | * add it to the document response object. 39 | * This props needs to take the following format: 40 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 41 | fetchLinks: PropTypes.oneOfType([ 42 | PropTypes.string, 43 | PropTypes.array, 44 | ]), 45 | /** It will order the results by the specified field(s). 46 | * You can specify as many fields as you want. 47 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 48 | * Use "desc" next to the field name to instead order it from greatest 49 | * to lowest e.g('[my.product.price desc]'). 50 | * You can specify more than one field to order your results by. To do so, 51 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 52 | * It is also possible to order documents by their first or 53 | * last publication dates e.g('[document.first_publication_date]'). */ 54 | orderings: PropTypes.string, 55 | /** The page option defines the pagination for the result of your query. 56 | * This value defaults to "1", corresponding to the first page. */ 57 | page: PropTypes.number, 58 | /** The pageSize option defines the maximum number of documents that the API 59 | * will return for your query. This value defaults to 20, max is 100. */ 60 | pageSize: PropTypes.number, 61 | }; 62 | 63 | QueryMonthBefore.defaultProps = { 64 | value: 1, 65 | component: undefined, 66 | after: undefined, 67 | fetch: undefined, 68 | fetchLinks: undefined, 69 | orderings: undefined, 70 | page: 1, 71 | pageSize: 20, 72 | }; 73 | -------------------------------------------------------------------------------- /src/components/QueryDayOfWeekAfter/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryDayOfWeekAfter checks that the value in the path 7 | * is after the day of the week passed. 8 | */ 9 | export default function QueryDayOfWeekAfter(props) { 10 | return ; 11 | } 12 | 13 | QueryDayOfWeekAfter.propTypes = { 14 | /** Defines what the query will be looking for. The different paths available are: 15 | * 'document.first_publication_date', 'document.last_publication_date' and 16 | * 'my.{custom-type}.{field}'. The last path is in the format 'my.{custom-type}.{field}' 17 | * where {custom-type} is the API ID of the custom type you want to query and {field} 18 | * is the API ID of the specific field in the custom type that you need. */ 19 | path: PropTypes.string.isRequired, 20 | /** Defines the value that the query is looking for. It is a number or string representing 21 | * the day of the week. e.g('monday', 'mon', or 1) */ 22 | value: PropTypes.oneOfType([ 23 | PropTypes.number, 24 | PropTypes.string, 25 | ]), 26 | /** The componet used to render the queried data. */ 27 | component: PropTypes.func, 28 | /** It will remove all the documents except for those after the specified document in the list. 29 | * By reversing the orderings in your query, you can use this same method to retrieve all 30 | * the documents before the specified document. */ 31 | after: PropTypes.string, 32 | /** It is used to make queries faster by only retrieving the specified field(s). */ 33 | fetch: PropTypes.oneOfType([ 34 | PropTypes.string, 35 | PropTypes.array, 36 | ]), 37 | /** It allows you to retrieve a specific content field from a linked document and 38 | * add it to the document response object. 39 | * This props needs to take the following format: 40 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 41 | fetchLinks: PropTypes.oneOfType([ 42 | PropTypes.string, 43 | PropTypes.array, 44 | ]), 45 | /** It will order the results by the specified field(s). 46 | * You can specify as many fields as you want. 47 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 48 | * Use "desc" next to the field name to instead order it from greatest 49 | * to lowest e.g('[my.product.price desc]'). 50 | * You can specify more than one field to order your results by. To do so, 51 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 52 | * It is also possible to order documents by their first or 53 | * last publication dates e.g('[document.first_publication_date]'). */ 54 | orderings: PropTypes.string, 55 | /** The page option defines the pagination for the result of your query. 56 | * This value defaults to "1", corresponding to the first page. */ 57 | page: PropTypes.number, 58 | /** The pageSize option defines the maximum number of documents that the API 59 | * will return for your query. This value defaults to 20, max is 100. */ 60 | pageSize: PropTypes.number, 61 | }; 62 | 63 | QueryDayOfWeekAfter.defaultProps = { 64 | value: 1, 65 | component: undefined, 66 | after: undefined, 67 | fetch: undefined, 68 | fetchLinks: undefined, 69 | orderings: undefined, 70 | page: 1, 71 | pageSize: 20, 72 | }; 73 | -------------------------------------------------------------------------------- /src/components/QueryFullText/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * Whit the QueryFulltext you can search a document or a text fragment for either 7 | * just one term or for multiple terms. To search for more than one term, put all 8 | * the terms into a string with spaces between them. 9 | * The full document search and specific field search works on the following fields: 10 | * Rich Text, Title, Key Text, UID, Select. 11 | */ 12 | export default function QueryFullText(props) { 13 | return ; 14 | } 15 | 16 | QueryFullText.propTypes = { 17 | /** Defines what the query will be looking for. The different paths available are: 18 | * 'document' and 'my.{custom-type}.{field}'. 19 | * The last path is in the format 'my.{custom-type}.{field}' 20 | * where {custom-type} is the API ID of the custom type you want to 21 | * query and {field} is the API ID of the specific field in the custom type that you need. */ 22 | path: PropTypes.string.isRequired, 23 | /** Defines the value that the query is looking for. */ 24 | value: PropTypes.string, 25 | /** The componet used to render the queried data. */ 26 | component: PropTypes.func, 27 | /** It will remove all the documents except for those after the specified document in the list. 28 | * By reversing the orderings in your query, you can use this same method to retrieve all 29 | * the documents before the specified document. 30 | */ 31 | after: PropTypes.string, 32 | /** It is used to make queries faster by only retrieving the specified field(s). */ 33 | fetch: PropTypes.oneOfType([ 34 | PropTypes.string, 35 | PropTypes.array, 36 | ]), 37 | /** It allows you to retrieve a specific content field from a linked document and 38 | * add it to the document response object. 39 | * This props needs to take the following format: 40 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 41 | fetchLinks: PropTypes.oneOfType([ 42 | PropTypes.string, 43 | PropTypes.array, 44 | ]), 45 | /** It will order the results by the specified field(s). 46 | * You can specify as many fields as you want. 47 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 48 | * Use "desc" next to the field name to instead order it from greatest 49 | * to lowest e.g('[my.product.price desc]'). 50 | * You can specify more than one field to order your results by. To do so, 51 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 52 | * It is also possible to order documents by their first or 53 | * last publication dates e.g('[document.first_publication_date]'). */ 54 | orderings: PropTypes.string, 55 | /** The page option defines the pagination for the result of your query. 56 | * This value defaults to "1", corresponding to the first page. */ 57 | page: PropTypes.number, 58 | /** The pageSize option defines the maximum number of documents that the API 59 | * will return for your query. This value defaults to 20, max is 100. */ 60 | pageSize: PropTypes.number, 61 | }; 62 | 63 | QueryFullText.defaultProps = { 64 | value: '', 65 | component: undefined, 66 | after: undefined, 67 | fetch: undefined, 68 | fetchLinks: undefined, 69 | orderings: undefined, 70 | page: 1, 71 | pageSize: 20, 72 | }; 73 | -------------------------------------------------------------------------------- /src/components/QueryDateAfter/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryDateAfter checks that the value in the path 7 | * is after the date value passed. 8 | */ 9 | export default function QueryDateAfter(props) { 10 | return ; 11 | } 12 | 13 | QueryDateAfter.propTypes = { 14 | /** Defines what the query will be looking for. The different paths available are: 15 | * 'document.first_publication_date', 'document.last_publication_date' and 16 | * 'my.{custom-type}.{field}'. The last path is in the format 'my.{custom-type}.{field}' 17 | * where {custom-type} is the API ID of the custom type you want to query and {field} 18 | * is the API ID of the specific field in the custom type that you need. */ 19 | path: PropTypes.string.isRequired, 20 | /** Defines the value that the query is looking for. It must be a Date object, a timestamp 21 | * or a string in the following format: 'YYYY-MM-DD'. */ 22 | value: PropTypes.oneOfType([ 23 | PropTypes.number, 24 | PropTypes.string, 25 | PropTypes.object, 26 | ]), 27 | /** The componet used to render the queried data. */ 28 | component: PropTypes.func, 29 | /** It will remove all the documents except for those after the specified document in the list. 30 | * By reversing the orderings in your query, you can use this same method to retrieve all 31 | * the documents before the specified document. */ 32 | after: PropTypes.string, 33 | /** It is used to make queries faster by only retrieving the specified field(s). */ 34 | fetch: PropTypes.oneOfType([ 35 | PropTypes.string, 36 | PropTypes.array, 37 | ]), 38 | /** It allows you to retrieve a specific content field from a linked document and 39 | * add it to the document response object. 40 | * This props needs to take the following format: 41 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 42 | fetchLinks: PropTypes.oneOfType([ 43 | PropTypes.string, 44 | PropTypes.array, 45 | ]), 46 | /** It will order the results by the specified field(s). 47 | * You can specify as many fields as you want. 48 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 49 | * Use "desc" next to the field name to instead order it from greatest 50 | * to lowest e.g('[my.product.price desc]'). 51 | * You can specify more than one field to order your results by. To do so, 52 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 53 | * It is also possible to order documents by their first or 54 | * last publication dates e.g('[document.first_publication_date]'). */ 55 | orderings: PropTypes.string, 56 | /** The page option defines the pagination for the result of your query. 57 | * This value defaults to "1", corresponding to the first page. */ 58 | page: PropTypes.number, 59 | /** The pageSize option defines the maximum number of documents that the API 60 | * will return for your query. This value defaults to 20, max is 100. */ 61 | pageSize: PropTypes.number, 62 | }; 63 | 64 | QueryDateAfter.defaultProps = { 65 | value: Date.now(), 66 | component: undefined, 67 | after: undefined, 68 | fetch: undefined, 69 | fetchLinks: undefined, 70 | orderings: undefined, 71 | page: 1, 72 | pageSize: 20, 73 | }; 74 | -------------------------------------------------------------------------------- /src/components/QueryDayOfWeekBefore/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryDayOfWeekBefore checks that the value in the path 7 | * is before the day of the week passed. 8 | */ 9 | export default function QueryDayOfWeekBefore(props) { 10 | return ; 11 | } 12 | 13 | QueryDayOfWeekBefore.propTypes = { 14 | /** Defines what the query will be looking for. The different paths available are: 15 | * 'document.first_publication_date', 'document.last_publication_date' and 16 | * 'my.{custom-type}.{field}'. The last path is in the format 'my.{custom-type}.{field}' 17 | * where {custom-type} is the API ID of the custom type you want to query and {field} 18 | * is the API ID of the specific field in the custom type that you need. */ 19 | path: PropTypes.string.isRequired, 20 | /** Defines the value that the query is looking for. It is a number or string representing 21 | * the day of the week. e.g('monday', 'mon', or 1) */ 22 | value: PropTypes.oneOfType([ 23 | PropTypes.number, 24 | PropTypes.string, 25 | ]), 26 | /** The componet used to render the queried data. */ 27 | component: PropTypes.func, 28 | /** It will remove all the documents except for those after the specified document in the list. 29 | * By reversing the orderings in your query, you can use this same method to retrieve all 30 | * the documents before the specified document. */ 31 | after: PropTypes.string, 32 | /** It is used to make queries faster by only retrieving the specified field(s). */ 33 | fetch: PropTypes.oneOfType([ 34 | PropTypes.string, 35 | PropTypes.array, 36 | ]), 37 | /** It allows you to retrieve a specific content field from a linked document and 38 | * add it to the document response object. 39 | * This props needs to take the following format: 40 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 41 | fetchLinks: PropTypes.oneOfType([ 42 | PropTypes.string, 43 | PropTypes.array, 44 | ]), 45 | /** It will order the results by the specified field(s). 46 | * You can specify as many fields as you want. 47 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 48 | * Use "desc" next to the field name to instead order it from greatest 49 | * to lowest e.g('[my.product.price desc]'). 50 | * You can specify more than one field to order your results by. To do so, 51 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 52 | * It is also possible to order documents by their first or 53 | * last publication dates e.g('[document.first_publication_date]'). */ 54 | orderings: PropTypes.string, 55 | /** The page option defines the pagination for the result of your query. 56 | * This value defaults to "1", corresponding to the first page. */ 57 | page: PropTypes.number, 58 | /** The pageSize option defines the maximum number of documents that the API 59 | * will return for your query. This value defaults to 20, max is 100. */ 60 | pageSize: PropTypes.number, 61 | }; 62 | 63 | QueryDayOfWeekBefore.defaultProps = { 64 | value: 1, 65 | component: undefined, 66 | after: undefined, 67 | fetch: undefined, 68 | fetchLinks: undefined, 69 | orderings: undefined, 70 | page: 1, 71 | pageSize: 20, 72 | }; 73 | -------------------------------------------------------------------------------- /src/components/QueryDateBefore/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryDateBefore checks that the value in the path 7 | * is before the date value passed. 8 | */ 9 | export default function QueryDateBefore(props) { 10 | return ; 11 | } 12 | 13 | QueryDateBefore.propTypes = { 14 | /** Defines what the query will be looking for. The different paths available are: 15 | * 'document.first_publication_date', 'document.last_publication_date' and 16 | * 'my.{custom-type}.{field}'. The last path is in the format 'my.{custom-type}.{field}' 17 | * where {custom-type} is the API ID of the custom type you want to query and {field} 18 | * is the API ID of the specific field in the custom type that you need. */ 19 | path: PropTypes.string.isRequired, 20 | /** Defines the value that the query is looking for. It must be a Date object, a timestamp 21 | * or a string in the following format: 'YYYY-MM-DD'. */ 22 | value: PropTypes.oneOfType([ 23 | PropTypes.number, 24 | PropTypes.string, 25 | PropTypes.object, 26 | ]), 27 | /** The componet used to render the queried data. */ 28 | component: PropTypes.func, 29 | /** It will remove all the documents except for those after the specified document in the list. 30 | * By reversing the orderings in your query, you can use this same method to retrieve all 31 | * the documents before the specified document. */ 32 | after: PropTypes.string, 33 | /** It is used to make queries faster by only retrieving the specified field(s). */ 34 | fetch: PropTypes.oneOfType([ 35 | PropTypes.string, 36 | PropTypes.array, 37 | ]), 38 | /** It allows you to retrieve a specific content field from a linked document and 39 | * add it to the document response object. 40 | * This props needs to take the following format: 41 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 42 | fetchLinks: PropTypes.oneOfType([ 43 | PropTypes.string, 44 | PropTypes.array, 45 | ]), 46 | /** It will order the results by the specified field(s). 47 | * You can specify as many fields as you want. 48 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 49 | * Use "desc" next to the field name to instead order it from greatest 50 | * to lowest e.g('[my.product.price desc]'). 51 | * You can specify more than one field to order your results by. To do so, 52 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 53 | * It is also possible to order documents by their first or 54 | * last publication dates e.g('[document.first_publication_date]'). */ 55 | orderings: PropTypes.string, 56 | /** The page option defines the pagination for the result of your query. 57 | * This value defaults to "1", corresponding to the first page. */ 58 | page: PropTypes.number, 59 | /** The pageSize option defines the maximum number of documents that the API 60 | * will return for your query. This value defaults to 20, max is 100. */ 61 | pageSize: PropTypes.number, 62 | }; 63 | 64 | QueryDateBefore.defaultProps = { 65 | value: Date.now(), 66 | component: undefined, 67 | after: undefined, 68 | fetch: undefined, 69 | fetchLinks: undefined, 70 | orderings: undefined, 71 | page: 1, 72 | pageSize: 20, 73 | }; 74 | -------------------------------------------------------------------------------- /src/components/QueryAt/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryAt checks that the path matches the described value exactly. 7 | * It takes a single value for a field or an array (only for tags). 8 | */ 9 | export default function QueryAt(props) { 10 | return ; 11 | } 12 | 13 | QueryAt.propTypes = { 14 | /** Defines what the query will be looking for. The different paths available are: 15 | * 'document.type', 'document.id', 'document.tags', and 'my.{custom-type}.{field}'. 16 | * The last path is in the format 'my.{custom-type}.{field}' where {custom-type} is 17 | * the API ID of the custom type you want to query and {field} is the API ID of the 18 | * specific field in the custom type that you need. */ 19 | path: PropTypes.string.isRequired, 20 | /** Defines the value that the query is looking for. Accept single value (string or number) 21 | * for all but 'document.tags' and array of values only for 'document.tags'. */ 22 | value: PropTypes.oneOfType([ 23 | PropTypes.number, 24 | PropTypes.string, 25 | PropTypes.array, 26 | ]), 27 | /** The componet used to render the queried data. */ 28 | component: PropTypes.func, 29 | /** It will remove all the documents except for those after the specified document in the list. 30 | * By reversing the orderings in your query, you can use this same method to retrieve all 31 | * the documents before the specified document. */ 32 | after: PropTypes.string, 33 | /** It is used to make queries faster by only retrieving the specified field(s). */ 34 | fetch: PropTypes.oneOfType([ 35 | PropTypes.string, 36 | PropTypes.array, 37 | ]), 38 | /** It allows you to retrieve a specific content field from a linked document and 39 | * add it to the document response object. 40 | * This props needs to take the following format: 41 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 42 | fetchLinks: PropTypes.oneOfType([ 43 | PropTypes.string, 44 | PropTypes.array, 45 | ]), 46 | /** It will order the results by the specified field(s). 47 | * You can specify as many fields as you want. 48 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 49 | * Use "desc" next to the field name to instead order it from greatest 50 | * to lowest e.g('[my.product.price desc]'). 51 | * You can specify more than one field to order your results by. To do so, 52 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 53 | * It is also possible to order documents by their first or 54 | * last publication dates e.g('[document.first_publication_date]'). */ 55 | orderings: PropTypes.string, 56 | /** The page option defines the pagination for the result of your query. 57 | * This value defaults to "1", corresponding to the first page. */ 58 | page: PropTypes.number, 59 | /** The pageSize option defines the maximum number of documents that the API 60 | * will return for your query. This value defaults to 20, max is 100. */ 61 | pageSize: PropTypes.number, 62 | }; 63 | 64 | QueryAt.defaultProps = { 65 | value: '', 66 | component: undefined, 67 | after: undefined, 68 | fetch: undefined, 69 | fetchLinks: undefined, 70 | orderings: undefined, 71 | page: 1, 72 | pageSize: 20, 73 | }; 74 | -------------------------------------------------------------------------------- /src/components/QueryMulti/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | const predicatesMap = { 6 | QueryAt: 'at', 7 | QueryFullText: 'fulltext', 8 | QueryNot: 'not', 9 | QueryAny: 'any', 10 | QueryIn: 'in', 11 | QueryHas: 'has', 12 | QueryMissing: 'missing', 13 | QuerySimilar: 'similar', 14 | }; 15 | 16 | export default function QueryMulti(props) { 17 | const { children } = props; 18 | const predicates = React.Children.map(children, (child) => { 19 | const { 20 | type: { name }, 21 | props: { path, value }, 22 | } = child; 23 | 24 | if (predicatesMap[name]) { 25 | return { 26 | predicate: predicatesMap[name], 27 | path, 28 | value, 29 | }; 30 | } 31 | return null; 32 | }); 33 | return ; 34 | } 35 | 36 | QueryMulti.propTypes = { 37 | /** The componet used to render the queried data. */ 38 | component: PropTypes.func, 39 | /** It will remove all the documents except for those after the specified document in the list. 40 | * By reversing the orderings in your query, you can use this same method to retrieve all 41 | * the documents before the specified document. 42 | */ 43 | after: PropTypes.string, 44 | /** It is used to make queries faster by only retrieving the specified field(s). */ 45 | fetch: PropTypes.oneOfType([ 46 | PropTypes.string, 47 | PropTypes.array, 48 | ]), 49 | /** It allows you to retrieve a specific content field from a linked document and 50 | * add it to the document response object. 51 | * This props needs to take the following format: 52 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 53 | fetchLinks: PropTypes.oneOfType([ 54 | PropTypes.string, 55 | PropTypes.array, 56 | ]), 57 | /** It will order the results by the specified field(s). 58 | * You can specify as many fields as you want. 59 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 60 | * Use "desc" next to the field name to instead order it from greatest 61 | * to lowest e.g('[my.product.price desc]'). 62 | * You can specify more than one field to order your results by. To do so, 63 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 64 | * It is also possible to order documents by their first or 65 | * last publication dates e.g('[document.first_publication_date]'). */ 66 | orderings: PropTypes.string, 67 | /** The page option defines the pagination for the result of your query. 68 | * This value defaults to "1", corresponding to the first page. */ 69 | page: PropTypes.number, 70 | /** The pageSize option defines the maximum number of documents that the API 71 | * will return for your query. This value defaults to 20, max is 100. */ 72 | pageSize: PropTypes.number, 73 | /** 74 | * This prop should not be visible in the documentation. 75 | * @ignore 76 | */ 77 | children: PropTypes.oneOfType([ 78 | PropTypes.arrayOf(PropTypes.node), 79 | PropTypes.object, 80 | ]), 81 | }; 82 | 83 | QueryMulti.defaultProps = { 84 | component: undefined, 85 | after: undefined, 86 | fetch: undefined, 87 | fetchLinks: undefined, 88 | orderings: undefined, 89 | page: 1, 90 | pageSize: 20, 91 | children: null, 92 | }; 93 | -------------------------------------------------------------------------------- /src/components/QueryDateBetween/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import Query from '../Query'; 4 | 5 | /** 6 | * The QueryDateBetween checks that the value in the path 7 | * is within the date values passed. 8 | */ 9 | export default function QueryDateBetween(props) { 10 | return ; 11 | } 12 | 13 | QueryDateBetween.propTypes = { 14 | /** Defines what the query will be looking for. The different paths available are: 15 | * 'document.first_publication_date', 'document.last_publication_date' and 16 | * 'my.{custom-type}.{field}'. The last path is in the format 'my.{custom-type}.{field}' 17 | * where {custom-type} is the API ID of the custom type you want to query and {field} 18 | * is the API ID of the specific field in the custom type that you need. */ 19 | path: PropTypes.string.isRequired, 20 | /** Defines the value that the query is looking for. Accept an object value with startDate 21 | * and endDate keys. Each one must be a Date object, a timestamp 22 | * or a string in the following format: 'YYYY-MM-DD'. */ 23 | value: PropTypes.shape({ 24 | startDate: PropTypes.oneOfType([ 25 | PropTypes.number, 26 | PropTypes.string, 27 | PropTypes.object, 28 | ]), 29 | endDate: PropTypes.oneOfType([ 30 | PropTypes.number, 31 | PropTypes.string, 32 | PropTypes.object, 33 | ]), 34 | }), 35 | /** The componet used to render the queried data. */ 36 | component: PropTypes.func, 37 | /** It will remove all the documents except for those after the specified document in the list. 38 | * By reversing the orderings in your query, you can use this same method to retrieve all 39 | * the documents before the specified document. */ 40 | after: PropTypes.string, 41 | /** It is used to make queries faster by only retrieving the specified field(s). */ 42 | fetch: PropTypes.oneOfType([ 43 | PropTypes.string, 44 | PropTypes.array, 45 | ]), 46 | /** It allows you to retrieve a specific content field from a linked document and 47 | * add it to the document response object. 48 | * This props needs to take the following format: 49 | * '{custom-type}.{field}' or ['{custom-type}.{field}', '{other-custom-type}.{field}'] */ 50 | fetchLinks: PropTypes.oneOfType([ 51 | PropTypes.string, 52 | PropTypes.array, 53 | ]), 54 | /** It will order the results by the specified field(s). 55 | * You can specify as many fields as you want. 56 | * It will automatically order the field from lowest to highest e.g('[my.product.price]'). 57 | * Use "desc" next to the field name to instead order it from greatest 58 | * to lowest e.g('[my.product.price desc]'). 59 | * You can specify more than one field to order your results by. To do so, 60 | * simply add more than one field in the array e.g('[my.product.price, my.product.title]'). 61 | * It is also possible to order documents by their first or 62 | * last publication dates e.g('[document.first_publication_date]'). */ 63 | orderings: PropTypes.string, 64 | /** The page option defines the pagination for the result of your query. 65 | * This value defaults to "1", corresponding to the first page. */ 66 | page: PropTypes.number, 67 | /** The pageSize option defines the maximum number of documents that the API 68 | * will return for your query. This value defaults to 20, max is 100. */ 69 | pageSize: PropTypes.number, 70 | }; 71 | 72 | QueryDateBetween.defaultProps = { 73 | value: {}, 74 | component: undefined, 75 | after: undefined, 76 | fetch: undefined, 77 | fetchLinks: undefined, 78 | orderings: undefined, 79 | page: 1, 80 | pageSize: 20, 81 | }; 82 | -------------------------------------------------------------------------------- /src/components/Query/index.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable react/prop-types */ 2 | import React, { Component } from 'react'; 3 | import PropTypes from 'prop-types'; 4 | import Prismic from 'prismic-javascript'; 5 | import ReactJson from 'react-json-view'; 6 | import Context from '../Prismic/context'; 7 | import resolveMultiPredicates from './resolve-multi-predicates'; 8 | import shouldFetch from './should-fetch'; 9 | import makeCancelablePromise from './make-cancelable-promise'; 10 | 11 | const VALID_PREDICATES = [ 12 | 'at', 13 | 'not', 14 | 'any', 15 | 'in', 16 | 'fulltext', 17 | 'has', 18 | 'missing', 19 | 'similar', 20 | 'near', 21 | 'lt', 22 | 'gt', 23 | 'dateAfter', 24 | 'dateBefore', 25 | 'dayOfMonth', 26 | 'dayOfMonthAfter', 27 | 'dayOfMonthBefore', 28 | 'dayOfWeek', 29 | 'dayOfWeekAfter', 30 | 'dayOfWeekBefore', 31 | 'month', 32 | 'monthAfter', 33 | 'monthBefore', 34 | 'year', 35 | 'hour', 36 | 'hourAfter', 37 | 'hourBefore', 38 | ]; 39 | 40 | export default function (props) { 41 | return ( 42 | 43 | {context => } 44 | 45 | ); 46 | } 47 | 48 | class Query extends Component { 49 | constructor(props) { 50 | super(props); 51 | this.state = { 52 | isLoading: false, 53 | }; 54 | } 55 | 56 | componentDidMount() { 57 | this.fetch(); 58 | } 59 | 60 | componentDidUpdate(prevProps) { 61 | if (shouldFetch(prevProps, this.props)) { 62 | this.fetch(); 63 | } 64 | } 65 | 66 | componentWillUnmount() { 67 | this.cancelablePromise.cancel(); 68 | } 69 | 70 | resolvePredicate() { 71 | const { 72 | predicate, 73 | path, 74 | value, 75 | multiPredicates, 76 | } = this.props; 77 | 78 | if (multiPredicates) { 79 | return resolveMultiPredicates(multiPredicates); 80 | } 81 | if (predicate === 'inRange') { 82 | return Prismic.Predicates.inRange(path, value.lowerLimit, value.upperLimit); 83 | } 84 | if (predicate === 'dateBetween') { 85 | return Prismic.Predicates.dateBetween(path, value.startDate, value.endDate); 86 | } 87 | if (VALID_PREDICATES.indexOf(predicate) !== -1) { 88 | return Prismic.Predicates[predicate](path, value); 89 | } 90 | return Prismic.Predicates.at(path, value); 91 | } 92 | 93 | queryPrismic() { 94 | const { 95 | repo, 96 | lang, 97 | ref, 98 | after, 99 | fetch, 100 | fetchLinks, 101 | orderings, 102 | page, 103 | pageSize, 104 | } = this.props; 105 | 106 | return Prismic.getApi(`https://${repo}.prismic.io/api/v2`) 107 | .then(api => api.query(this.resolvePredicate(), { 108 | after, 109 | fetch, 110 | fetchLinks, 111 | lang, 112 | orderings, 113 | page, 114 | pageSize, 115 | ref, 116 | })); 117 | } 118 | 119 | fetch() { 120 | this.setState({ isLoading: true }); 121 | this.cancelablePromise = makeCancelablePromise( 122 | this.queryPrismic(), 123 | ); 124 | this.cancelablePromise 125 | .promise 126 | .then((response) => { 127 | this.setState({ response, isLoading: false }); 128 | }) 129 | .catch((error) => { 130 | if (!error.isCanceled) { 131 | this.setState({ error, isLoading: false }); 132 | } 133 | }); 134 | } 135 | 136 | render() { 137 | const { response, error, isLoading } = this.state; 138 | const { component: RendererComponent, ...rest } = this.props; 139 | 140 | return ( 141 | 147 | ); 148 | } 149 | } 150 | 151 | Query.propTypes = { 152 | predicate: PropTypes.oneOf([ 153 | 'at', 154 | 'not', 155 | 'any', 156 | 'in', 157 | 'fulltext', 158 | 'has', 159 | 'missing', 160 | 'similar', 161 | 'near', 162 | 'lt', 163 | 'gt', 164 | 'inRange', 165 | 'dateAfter', 166 | 'dateBefore', 167 | 'dateBetween', 168 | 'dayOfMonth', 169 | 'dayOfMonthAfter', 170 | 'dayOfMonthBefore', 171 | 'dayOfWeek', 172 | 'dayOfWeekAfter', 173 | 'dayOfWeekBefore', 174 | 'month', 175 | 'monthAfter', 176 | 'monthBefore', 177 | 'year', 178 | 'hour', 179 | 'hourAfter', 180 | 'hourBefore', 181 | ]), 182 | path: PropTypes.string, 183 | value: PropTypes.any, 184 | component: PropTypes.func, 185 | after: PropTypes.string, 186 | fetch: PropTypes.oneOfType([ 187 | PropTypes.string, 188 | PropTypes.array, 189 | ]), 190 | fetchLinks: PropTypes.oneOfType([ 191 | PropTypes.string, 192 | PropTypes.array, 193 | ]), 194 | orderings: PropTypes.string, 195 | page: PropTypes.number, 196 | pageSize: PropTypes.number, 197 | multiPredicates: PropTypes.array, 198 | }; 199 | 200 | Query.defaultProps = { 201 | predicate: 'at', 202 | path: 'document.type', 203 | value: '', 204 | component: ({ response }) => , 205 | after: undefined, 206 | fetch: undefined, 207 | fetchLinks: undefined, 208 | orderings: undefined, 209 | page: 1, 210 | pageSize: 20, 211 | multiPredicates: undefined, 212 | }; 213 | -------------------------------------------------------------------------------- /.firebase/hosting.c3R5bGVndWlkZQ.cache: -------------------------------------------------------------------------------- 1 | asset-manifest.json,1539843587455,070b695da567d6091b739b946d3010af8b6435d041e9074a53e1420f659cc4b7 2 | index.html,1539843587455,46188bd1875e64649bacb77b54d87372509adf23619939a61f559fc131c5dec1 3 | build/bundle.7b491809.js,1539843587490,b6a85e33fb96e04ca3f268c370a832d45f7c8b1723ab54c0ad6bf2f15b9e54eb 4 | build/main.ecfd3774.js,1539843587458,96ffab9b247532a0d0855b19418cbc7974367e52e9f1cce652b33711b7640612 5 | static/media/Lato-Black.9ab28490.woff2,1539843587484,081d08352928d6f0f9d7fdfef43955eed3262491acd5b25c7ec6b855e742b20e 6 | static/media/Lato-BlackItalic.3a9f8a8c.woff2,1539843587485,38b023aa2413e0deb0d94db11cf83f407ec16b0766413c8ed86ea229cf1a5136 7 | static/media/Lato-Bold.cfc7a0ef.woff2,1539843587485,70bcf8db4e096bb8e231aa1d54116dc38c69c1af36777bd348cd1f0fa40e0e6f 8 | static/media/Lato-Hairline.9353e4f9.woff2,1539843587486,61d3661d8716655e73afee6bd04b66f1d0e27193ac2aacf509043e5fda99b5c0 9 | static/media/Lato-HairlineItalic.51e3f958.woff,1539843587487,99db3010f0125b2809b6ff84e857f00b3e5da80943c86740252d9448fe246514 10 | static/media/Lato-HairlineItalic.d1b4f2b6.woff2,1539843587486,d5f891bfd454e3728d84ed8f5fb38ed22d920b6ba8b8549bbaf9677bd4ab0c84 11 | static/media/Lato-Hairline.a0126eff.woff,1539843587486,26e3cd902d298928017358f48a73d6f6482989f1aabe4b1f7b05597eb8a8e143 12 | static/media/Lato-Light.96b78ec9.woff2,1539843587487,9bf9d862f66f9aef43fee3130cf2768f1947b52618643edda5cdd80e23a4f028 13 | static/media/Lato-LightItalic.a0d2a3a8.woff2,1539843587488,e9bcf949c8b51bb8f20fc6b37c1c6c15ac970d3d35e4915e4fe1cc0c7648a27e 14 | static/media/Lato-LightItalic.e4669f8c.woff,1539843587488,93cfec1f2119f7f7334b24fba40302774990474a3c66e32a0652182ec602e9ad 15 | static/media/Lato-Black.21c4d25c.woff,1539843587484,16c5b32f192ba71590f75f1d97be0ddf2e33feb78fe09c51bf6a3b091c69fde0 16 | static/media/Lato-BlackItalic.eb70fa8a.woff,1539843587484,6c9e35df465a1769a4160bf9b015facd307b7d420523ab4209783e639def4443 17 | static/media/Lato-Bold.5dfc529d.woff,1539843587485,7c61fda30f632edf3052dd0a893c6a771e6b8f84f7174e3cbecf5eec4d6847d3 18 | static/media/Lato-BoldItalic.104d6a88.woff2,1539843587485,ba0b1b6c851f96590469e292ae44a552ca9004b56b9d4604978475715360398d 19 | static/media/Lato-BoldItalic.5a5f0723.woff,1539843587485,8843d7f7d202b0647df89bf934602ac9c8642794a3ec62de698eec5dee301ea7 20 | static/media/Lato-Italic.3ecfbc65.woff,1539843587487,7ace288d3a8f33f509d7d6651b97b90903dbd5f484c672765e12434420280dc8 21 | static/media/Lato-Light.9d57e0c9.woff,1539843587487,8c92144e86fc04c59af73461311714ae395eebc4e0bdfa8c046694c42f90876e 22 | static/media/Lato-Italic.b441b790.woff2,1539843587487,b62e8aeff3ea95727f295c6b03783575b9ebcfaba321b8096f4f08fa433edf23 23 | static/media/Lato-HairlineItalic.f5bafa9a.eot,1539843587486,c6212b24c1267b34bcac7717cebd2dead3fe0ab506a4d77779590fafb45fca12 24 | static/media/Lato-HairlineItalic.a567f4a8.ttf,1539843587486,64badf8ab5a032b8a3387aa7e146e6179224369d872d3189dbe392c3c6a3f9f1 25 | static/media/Lato-LightItalic.3d747d8b.ttf,1539843587487,1798325a849f2dc1746116456624053835e302b57861dc33c046158d7d129d84 26 | static/media/Lato-LightItalic.88376c87.eot,1539843587487,1de2001ee1e9884f63b98a256e56d652d947c44eee3df9a3692450063433ef35 27 | static/media/Lato-Black.77d35374.ttf,1539843587484,8af3b1bb169794ac6175e5b03207da686308cbc8b92afcbeb53de3d8ad1a15f9 28 | static/media/Lato-BlackItalic.16d065a7.eot,1539843587484,25de1cfa4984f92a30206fd7da8f8d8d88bb0c2d0d6c23e6a2fb3371584c8fea 29 | static/media/Lato-Black.f21ec1ef.eot,1539843587484,671437d680f0a162f03c871b26fa3a3f8becb90711c0b36fdfc75c32726b5fd0 30 | static/media/Lato-Bold.44dfe8cc.ttf,1539843587485,d466f6da524070000392acb96d8071e48e726e0129040be2eee967175c6f764d 31 | static/media/Lato-Bold.a47d8f9c.eot,1539843587484,adb2df75203b10864ecfa0aace0122560979736f4dfbda15c402d26ea2fed604 32 | static/media/Lato-BoldItalic.1ba4767e.ttf,1539843587485,8b61cb5a1b69a23c90035f1b1a7a3c56d83511200b357310ff9e1fd546a02413 33 | static/media/Lato-BlackItalic.6c522f09.ttf,1539843587485,d35b51639cad088af122c813226d8abfd59062a4f9500991d9f5221d1ba2a819 34 | static/media/Lato-BoldItalic.15518f50.eot,1539843587485,85699931904fdbf2db2e127d02509f0e2b946625cd6b15d4bd4e096d8d2139d7 35 | static/media/Lato-Hairline.db15ac79.ttf,1539843587486,ee7496e692223009feec396c58600d4ca95bec15eeaa9885965bbb64aeed3121 36 | static/media/Lato-Hairline.cc02ace7.eot,1539843587486,0711072274887e374f5cea0558671f2868d52610b829f13b210b6855f32f9895 37 | static/media/Lato-Italic.56c4cb26.ttf,1539843587487,66d305a50b6117de2b7d2538d538ff74a46226a003a4c21f7fd2ff10a793b7ef 38 | static/media/Lato-Italic.af5a576d.eot,1539843587486,e469b75f6ec130e2628ba589a9c75385bea06a4212ddf5387a4ae26cd3569363 39 | static/media/Lato-Light.5b761f2d.ttf,1539843587487,49649ed370c0be1a050846f469e45112be04e240b83d33935757ddcd54d7a10f 40 | static/media/Lato-Regular.3679ad95.woff2,1539843587488,733a32312c59e35d7a45f80a7bf9e200c096acbb0fa40d23c20de05e4d151c7b 41 | static/media/Lato-Light.f014a7e8.eot,1539843587487,41a2bfdf7a12cdebfd33139f8b3a195c438705c4b44cbd564001aff7017d728b 42 | static/media/Lato-Regular.e4fa05a4.woff,1539843587488,af8e541bb9f6a656d0b80d3b09ee0dfa4d9626dfe349c3ea949d138aa757beba 43 | static/media/Lato-Black.cb6fe25e.svg,1539843587484,a23fdacf669c9da3491e2e50535701e778912325957905792e2bf64945ca5c01 44 | static/media/Lato-BlackItalic.5fc797bf.svg,1539843587484,7f8c2252d4d6e7bae0cdf698575cbdd77efbbb2c9d977c6a2ef6cb3f22b38543 45 | static/media/Lato-Regular.39a39050.eot,1539843587488,af74ffbbbb8b6fdfe652cd74127cab05cd2e5e228d05229e671ba3a2a03331bc 46 | static/media/Lato-HairlineItalic.8f30b438.svg,1539843587486,3a56e62bc8ed66c1fdc5fcacb141f742fe6230bc3bcf3db43583b4f2766afdca 47 | static/media/Lato-Hairline.e5d453c9.svg,1539843587486,84d8617b8abf7b0cfc0e0fe99128c3d5f39b2954c1b9b0b529c9521332199419 48 | static/media/Lato-Regular.7f690e50.ttf,1539843587488,c4db30c6927306699a4a7d4043e6f0298ca4f7b331c02e473b87c76aaa9d694a 49 | static/media/Lato-Italic.1ffe5066.svg,1539843587487,7ff118cb45cd6bce440dfb3fc6edc2cf39847eb1318a7130496aea5efcb61e5a 50 | static/media/Lato-BoldItalic.4a4cd2e7.svg,1539843587485,f62e6172beeca0972172d9a1faa8b775109d0afee930c679d47949746c69b53d 51 | static/media/Lato-Bold.e05bae7c.svg,1539843587485,5e0dab7df5f506ef75c03f6233354e31033eba8990b9e3975154723595074415 52 | static/media/Lato-LightItalic.75da51e5.svg,1539843587487,fbcb703cdad17a1f7faf895b29c1644872553fae3783f2e0da385cd61ce34ade 53 | static/media/Lato-Light.b13b187d.svg,1539843587487,d332d011995bec879723f1223c4fa558cecdac92b6ae2b18ce1ec5a81f4b4c73 54 | static/media/Lato-Regular.e9d329fb.svg,1539843587488,ed86533a013365a98246a4d94c2b0389a8a7aff112ab91bf8e3629d1a3bc7a25 55 | build/0.7f65a164.js,1539843587490,bb1f4af59139b168454dbec5623f1cdb8e5472a202c76831b8786aab013772be 56 | -------------------------------------------------------------------------------- /public/images/react-prismic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | react-prismic 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /public/images/broccoli-florets.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | --------------------------------------------------------------------------------