ℹ️ 2024 April 4th: Archiving the repository since we decided to instead improve the official Contentful Color picker by contributing to their repository.
This project was bootstrapped with Create Contentful App.
If you've found any issues, please open an issue here: https://github.com/adaptdk/adapt-toolkit-color-picker/issues
If you think the application is missing any features, please open an issue here: https://github.com/adaptdk/adapt-toolkit-color-picker/issues
- Examples
- How to use the Application
- Developing
- Available scripts
- Libraries to use
- Contentful Management SDK
- Learn more
Once the application is successfully installed, you will be directed to the configuration screen. There you can find basic instructions on how to start building your design system. In the Editing Options, there will be a preconfigured Default group with a single color inside of it.
Clicking the + Add Color button will create a new color in the group
To change the label of the color, simply type it in the LABEL field of a color.
To change a color, you have two options:
- Edit the
#HEX
value directly in the input field labeled as HEX; - Click on the color box to open a color picker;
To remove a color bar, simply click the red trash bin icon.
To edit settings of a group, simply click the pencil icon in the GROUP SETTINGS "box"
More advanced users can instead use the JSON Editor to configure their color groups and colors.
Each item's ID is generated via uuidv4.
ℹ️ Pro tip: Instead of generating IDs yourself, create multiple default placeholder items - they will already come with an ID!
After you're done configuring your color design system, using it is extremely simple!
- Create a new Text field in your content type
- In the newly created field's settings, scroll down to the Appearance section and select Adapt Essentials: Colors
- After you save your content type, you're done and ready to use the field!
- Go to your field's settings, scroll down to Validation and select the Accept only specified values checkbox. Simply input the LABEL value of a color and hit enter. In our example, we have a color of
"hexColor": "#0f6ad2"
and"label": "blue-500"
, so we're going to inputblue-500
in to the validation field.
- After you save your content type, you're done and ready to use the validated field!
Querying the field is the same as querying a basic text field. So if your field is called color
, that's what the API response will respond to.
The returned value is the LABEL, so in our example of "hexColor": "#0f6ad2"
and "label": "blue-500"
, the returned value would be color: 'blue-500'
Execute create-contentful-app with npm, npx or yarn to bootstrap the example:
# npx
npx create-contentful-app --example vite-react
# npm
npm init contentful-app --example vite-react
# Yarn
yarn create contentful-app --example vite-react
In the project directory, you can run:
Creates or updates your app definition in Contentful, and runs the app in development mode. Open your app to view it in the browser.
The page will reload if you make edits. You will also see any lint errors in the console.
Builds the app for production to the dist
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes. Your app is ready to be deployed!
Uploads the dist
folder to Contentful and creates a bundle that is automatically activated.
The command guides you through the deployment process and asks for all required arguments.
Read here for more information about the deployment process.
Similar to npm run upload
it will upload your app to contentful and activate it. The only difference is
that with this command all required arguments are read from the environment variables, for example when you add
the upload command to your CI pipeline.
For this command to work, the following environment variables must be set:
CONTENTFUL_ORG_ID
- The ID of your organizationCONTENTFUL_APP_DEF_ID
- The ID of the app to which to add the bundleCONTENTFUL_ACCESS_TOKEN
- A personal access token
To make your app look and feel like Contentful use the following libraries:
- Forma 36 – Contentful's design system
- Contentful Field Editors – Contentful's field editor React components
In the default create contentful app output, a contentful management client is passed into each location. This can be used to interact with Contentful's management API. For example
// Use the client
cma.locale.getMany({}).then((locales) => console.log(locales));
Visit the contentful-management
documentation
to find out more.
Read more and check out the video on how to use the CLI.