Giter Site home page Giter Site logo

kontent-ai / sample-app-react Goto Github PK

View Code? Open in Web Editor NEW
51.0 31.0 72.0 6.83 MB

Sample React SPA utilizing the Kontent.ai Delivery API to fetch content.

Home Page: https://kontent-sample-app-react.netlify.app/

License: MIT License

HTML 0.24% CSS 41.00% TypeScript 58.76%
react spa headless-cms content-delivery caas kontent-sample hacktoberfest kontent-ai kontent-ai-sample

sample-app-react's Introduction

Kontent.ai sample React single-page application

Netlify Status Live Demo Stack Overflow

This is a sample website written in Typescript utilizing the Kontent.ai Delivery API to retrieve content from Kontent.ai. You can register your developer account at https://app.kontent.ai. For a brief walkthrough, check out Running the React sample app at Kontent.ai Learn.

Application setup

  1. Install the latest version of NodeJS and npm. You can download both at https://nodejs.org/en/download/.
  2. Clone the sample application repository.
  3. Navigate to the root folder of the application in the command line.
  4. Type npm install to install required npm packages.
  5. Type npm start to start a development server.
  6. The application opens in your browser at http://localhost:3000.

Connecting to your sample project

At the first run of the app, you'll be presented with a configuration page. It will allow you to connect the app to your Kontent.ai project or create a new one. You'll also be able to start a trial and convert to a free plan when the trial expires.

Alternatively, you can connect your project manually as per the chapter below.

Connecting to your project manually

If you want to change the source Kontent.ai project, follow these steps:

  1. In Kontent.ai, choose Project settings from the app menu.
  2. Under Development, choose API keys.
  3. Copy your Environemnt ID.
  4. Open .env.example in the root directory.
  5. Replace your_environment_id with your Environment ID and remove REACT_APP_PREVIEW_API_KEY entry.
  6. Save and rename the file .env.

When you now run the sample application, the application retrieves content from your project.

Get creative

Deploy, explore and change the app directly in the browser.

Remix on Glitch

Deploy to Netlify

Previewing content from your project

If you already have a Kontent.ai account and you want to connect the sample application to a project of your own, you need to provide your Environment ID and your Preview API key to authorize requests to the Delivery Preview API. For example, you can connect the application to your modified version of the sample project.

To preview content in the sample application, follow these steps:

  1. In Kontent.ai, choose Project settings from the app menu.
  2. Under Development, choose API keys.
  3. Copy your Environemnt ID and Preview API key.
  4. Open .env.example in the root directory .
  5. Replace your_environment_id and your_api_key with your Environment ID and Preview API key.
  6. Save and rename the file .env.

When you now run the application, you will see all project content including the unpublished version of content items.

Content administration

  1. Navigate to https://app.kontent.ai in your browser.
  2. Sign in with your credentials.
  3. Manage content in the content administration interface of your sample project.

You can learn more about content editing in our tutorials at Kontent.ai Learn.

Content delivery

You can retrieve content either through the Kontent.ai Delivery SDKs or the Kontent.ai Delivery API:

  • For published content, use https://deliver.kontent.ai/ENVIRONMENT_ID/items.
  • For unpublished content, use https://preview-deliver.kontent.ai/ENVIRONMENT_ID/items.

For more info about the API, see the API reference.

You can find the Delivery and other SDKs at https://github.com/kontent-ai.

Used toolchain

This application is based on the Create React App using the following template --template typescript.

Model mapping and data fetching

There are two types of model mapping in this application:

content type -> DTO -> component

Content type definitions are being generated from content types via Kontent.ai model generator tool. All generated types can be found in src/Models folder. The _project.ts contains information about the project structure such as project languages as well as other structure information like codenames about content types.

content type -> DTO -> view model -> component

Some models displayed in views might require an adjustment from content types. For example, the Cafe content type contains fields for city and street and we would like to have a model containing an address in the format city, street. An example of such a view model is in CafeModel.tsx that can be found in the src/ViewModels folder. To convert Cafe into CafeModel the function located in src/Utilities/CafeListing.ts can be used.

Data fetching

This solution fetches data using the Delivery client. For more implementation detail to set up the client see src/Client.ts. The data are fetched and stored in a container component directly in its state. Then they are passed to the presentation component. For a better understanding see the code example below. However, depending on your needs, you can use other technologies for managing application states such as:

const Component: React.FC = () => {
    const [data, setData] = useState<GeneratedDTO[]>([]);


    useEffect(() => {
      const query = Client.items<GeneratedDTO>()
          .type(projectModel.contentTypes.generatedDTO.codename)
          ...

      query.ToPromise()
          .then(data => setData(data.items));
    }, []);

    return (
        {data.map(item => <DisplayItem dto={item}/>)}
    );
    ...
}

Filtering by taxonomy

Filters in Kontent.ai are implemented using taxonomies. Filtering examples can be found in src/Components/BrewerStoreContainer.tsx or src/Components/CoffeeStoreContainer.tsx. Firstly, the taxonomies groups that contain possible values for filters are loaded in useEffect blocks. Selected values for filtering are stored in the filter variable. Items to be displayed are then selected with the functional filter function checking whether the item matches the filter.

interface FilterType {
  [index: string]: string[];
  processings: string[];
  productStatuses: string[];
}

const Container: React.FC = () => {
    const [processings, setProcessings] = useState<ITaxonomyTerms[]>([]);
      const [productStatuses, setProductStatuses] = useState<ITaxonomyTerms[]>([]);

      const [filter, setFilter] = useState<FilterType>({
          processings: [],
          productStatuses: [],
      });

      useEffect(() => {
          Client.taxonomy('processings')
            .toPromise()
            .then((response) => {setProcessings(response.data.taxonomy.terms);});
      }, []);

      useEffect(() => {
          Client.taxonomy('product_status')
            .toPromise()
            .then((response) => {setProductStatuses(response.data.taxonomy.terms);});
      }, []);

      const matches = (coffee: Coffee): boolean =>
          matchesTaxonomy(coffee, filter.processings, 'processings') &&
          matchesTaxonomy(coffee, filter.productStatuses, 'productStatuses');
      // To see how matchesTaxonomy can work see src/Utilities/CheckboxFilter

      const toggleFilter = (filterName: string, filterValue: string): void => {
          setFilter((filter) => ({
            ...filter,
            [filterName]: filter[filterName].includes(filterValue)
            ? filter[filterName].filter((x: string) => x !== filterValue)
            : [...filter[filterName], filterValue],
            }));
      };.

      return (
          <div>
              ...
              <CheckboxFilter
              ...
              onChange: (event) => toggleFilter('processings', event.target.id),
              />
           ...
              <ItemListing
               items={ items[language].filter((item: ItemDTO) =>matches(coffee)) }
               />
           ...
           </div>
      );
}

Localization

In Kontent.ai each language is identified by codename, in case of this project, it is en-US and es-ES.

Resource strings

Not every text of the application must be stored in Kontent.ai. Some strings, such as button texts, navigation texts, and so on, can be stored directly in the application. For those texts React-intl is used. For every language, there is a JSON file in src/Localization folder.

React-intl can not parse nested JSON objects and therefore the format of files is key:value. To load all files from src/Localization folder there is a src/utilities/LocalizationLoader.ts script.

// en-US.json
{
  "LatestArticles.title": "Latest articles",
  "LatestArticles.noTitleValue": "(Article has no title)",
  "LatestArticles.noTeaserValue": "(Article has no teaser image)",
  "LatestArticles.noSummaryValue": "No summary filled"
  // ...
}

Language prefixes

The language prefix is obtained from the URL in the LocalizedApp.tsx and then it is propagated via IntlProvider to the whole application. Content language is then adjusted by modifying Client with languageParameter() method to obtain items in a specific language. By default it uses language fallbacks set up in the project.

const Component: React.FC = () => {
  const { locale: language } = useIntl();

  useEffect(() => {
    const query = Client.items<ItemDTO>()
      .type(projectModel.contentTypes.itemDTO.codename);

    if (language) {
      query.languageParameter(language);
    }
    ...

Localizable URL slugs

You might want to request items based on the URL slugs. For more information check out Kontent.ai/learn tutorial. An example in this application for this is provided in src/Pages/About.tsx page.

The showcase is not ideal, because it is using a combination of the language prefixes and localizable routes. You should try to stick with one of the approaches. Because it is hard to define the behavior (priority) for language setting clashes like `//articles/.

Language fallbacks

To deal with content that is not available in current language, this project uses method called language fallbacks. It will fetch the content in the language which set as fallback language in the Kontent.ai project and redirect the website to the URL with prefix of the given language. However, it is possible to disable language fallbacks by adding a filter of system.language to your query. For more information about getting localized content check this link.

var query = Client.items<AboutUs>().type(contentTypes.about_us.codename);

if (this.language) {
    query
    .languageParameter(this.language)
    .equalsFilter('system.language', 'es-ES');
}

Handling 404

For the not found resources, prefixed 404 pages are used for both languages. As the content on one page should be in one language, this approach might help you to optimize SEO. If language is not set in the URL the application uses the last used language, which is set in cookies.

Deployment

You can use eg. surge to deploy your app live. Check out the step-by-step guide on our blog.

Wall of Fame

We would like to express our thanks to the following people who contributed and made the project possible:

Would you like to become a hero too? Pick an issue and send us a pull request!

sample-app-react's People

Contributors

alesk-kentico avatar ankurg22 avatar beemtz avatar caseydbrown avatar cbeard87 avatar christopherjennings avatar dependabot-preview[bot] avatar dependabot[bot] avatar dhruvamsharma avatar dunklestoast avatar enngage avatar hejtmii avatar iamlucie avatar ivankiral avatar jancerman avatar jmb521 avatar juraju-kentico avatar karl-edwardfpjeanmehu avatar kontent-ai-bot avatar liamgold avatar maartenhvdh avatar petrsvihlik avatar sca88 avatar sheidaee avatar simply007 avatar ssiddhantsharma avatar third774 avatar tobiaskamenicky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sample-app-react's Issues

Add a showcase of the content type snippets

Kentico Cloud now supports so called content type snippets. These are sets of content elements that can be added to multiple content types to enrich their structure but still be managed from a single place.

The Delivery API responses contain both the elements originating from snippets alongside their own elements. The only difference is that snippets have code names prefixed with the code name of the respective snippet. The format of code names is [code name of snippet]__[code name of element].

A shortened example of a content item:

{
    "item": {
        "system": {
            // ...
            "type": "brewer",
	// ...
        },
        "elements": {
	// ...
            "product_name": {
                "type": "text",
                "name": "Product name",
                "value": "AeroPress"
            },
	// ...
            "metadata__meta_title": {
                "type": "text",
                "name": "Meta title",
                "value": null
            },
	// ...
        }
    },
    "modular_content": {}
}

The goal of this task is to implement support for rendering content items of content types that utilize a content snippet. For that scenario, we've prepared a sample content snippet that enriches other content types with SEO-related data, such as og:title, og:description, etc. which are then rendered in the <head> of the page.

Suggested approach:

  • use the model generator to regenerate the models (in order for them to have the desired og-related properties)
  • adjust the code of the sample application so that it renders the SEO metadata in the <head> of the page

Extract API keys definition to .env

Motivation

@Simply007 originally logged an issue against the Vue sample project, which would probably be a good idea for the react sample project too.

See kontent-ai/sample-app-vue#23 (comment) for detailed information.

The general idea is to move the recommended configuration of sensitive key information from the Client.js file into git ignored .env.* files.

Proposed solution

Best practice nowadays is to use environment variables stored in .env file.

  • Set up .gitignore to ignore .env file
  • Configure Client.js to use .env definition for keys (projectId and previewApiKey)
  • Update Readme

Additional context

Url slug is not set in models

Loading content using typescript SDK raise a warning that URL slug is not implemented:

  • You have to implement 'urlSlugResolver' in your Model class or your query in order to get url of this item
    field-types.js:196

i.e. Home page raise this warning 9 times.

Consequences on the content, that uses some links in rich text does not resolve them properly.
Example:
Link in article detail (http://localhost:3000/#/articles/coffee-processing-techniques)
contains link to Brazil Natural Barra Grande (content type Coffee) is not resolve
Expected:
http://localhost:3000/#/store/coffees/brazil-natural-barra-grande
But is
http://localhost:3000

image

Remove deprecated (UNSAVE_) methods in ContactMap component

Motivation

As a followup for issue #97, there is one component left with lifecycle method with prefix UNSAVE. In the react v17, it is required to remove those methods, because they are about to be deleted.

Proposed solution

Use different lifecycle methods as a substitution for the deprecated ones.

There are 2 occurrences of UNSAFE_componentWillUpdate and one of UNSAFE_componentWillReceiveProps.

Additional context

Current features on Contacts page:
If a user clicks on the address on Contacts (/contacts) page, the page is scrolled to the map and the address is focused on the map. Event when switching the languages.

See also related issues #97, #105, #99 for more information.

Image Sliders don't Work in the React Sample App

Hey guys I am evaluating Kentico Kontent for an application but nearly everything I am trying is being overwritten by the out of the box CSS in the Sample App.

I have tried 3-4 different image slider packages and they all break out of the box.

I settled on https://swiperjs.com/ but it is breaking out of the box.

Should I be using the sample app as a starting point? I essentially want a blank slate to develop on.

I have dropped index.css completely yet most rules are being overwritten
image

There is nothing in the computed that I can see will tell me where these rules are being overwritten. I am at the point that I am going to have to start tearing out large chunks of the Sample App.

What am I doing wrong?

[Spike] Prepare multilingual setup

Expected result

Additional context

  • Mind there are 2 sources of the data - Kontent and JSON
  • We would like to preserve the different date/time format for different languages
  • There are language prefixes showcased + URL slug for about-us/arcera-de (we might cut out one of these)
  • Articles are identified by ID in the URL

Update integration sample - Google analytics

Brief bug description

After the rebranding from Kentico Cloud to Kentico Kontent there are still some samples that use old naming in branches named samples/*.

Until the end of October endpoint on domain kenticocloud.com stop working and there will be redirect performed:

Expected behavior

Transfer changes made in #140 to the samples/ga branch

  • Update dependency from kentico-cloud-delivery to @kentico/kontent-delivery
    • adjust the breaking changes
  • Update dependency @chevtek/react-spinners to @simply007org/react-spinners
    • no breaking changes
  • Rename Kentico Cloud to Kentico Kontent
  • adjust travis.yml to use the correct domain for deployment

Add ESLint & unify coding style

There are some inconsistencies in code style, especially in the use of apostrophes vs double quotes.

Example:

import { resolveContentLink } from '../Utilities/ContentLinks'
import BrewerStore from "../Stores/Brewer";

Suggested approach:

  • fix the ESLint configuration in this project
    • there are some standard configs available on the web
    • ideally, configure ESLint to fix issues automatically
  • use ESLint to identify issues and fix them

Upgrade to npm lockfile v2

It would be great if the npm lockfile gets upgraded to version 2 which is used by npm v7 or later, since the new lockfile has some great features and advantages in comparison to the lockfile v1. As far as I know, this would drop support for npm v6.

If you are fine with upgrading to the new lockfile, let me know. I'll create a PR for that!

Missing typescript in dev dependencies

Brief bug description

This error can occur when starting

Error: Cannot find module 'typescript' from 'G:\work\kontent-sample-app-react\node_modules'
at Function.resolveSync [as sync] (G:\work\kontent-sample-app-react\node_modules\resolve\lib\sync.js:111:15)
at getModules (G:\work\kontent-sample-app-react\node_modules\react-scripts\config\modules.js:119:32)
at Object.<anonymous> (G:\work\kontent-sample-app-react\node_modules\react-scripts\config\modules.js:142:18)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (G:\work\kontent-sample-app-react\node_modules\react-scripts\config\webpack.config.js:28:17) {
code: 'MODULE_NOT_FOUND'

Repro steps

  1. Clone repo
  2. Run npmi
  3. Run `npm start
  4. See error (if you don't have typescript installed globaly)

Expected behavior

No error

Additional context

Solution is to add typescript in dev dependencies.

Put the kontent client into a react context

Motivation

It would better fit into the React flow to have the client inside a react context or state. (context avoids props drilling compared to state). As it now stands, once you reset the client, React doesn't ensure that your components get re-rendered with the new client (project id). If the client would be part of the React flow (i.e. in a context or a state) react would re-render your components and ensure you always render the freshest data.

Proposed solution

Put the Kontent.ai client into a React context instead of having it in a global mutable variable.

Cannot leave configuration in web spotlight

Brief bug description

When I open the sample app in the web spotlight, I can't leave the configuration page. Submitting the form doesn't work, because the cookie is not accessible to the page in the iframe. You need to set the SameSite=None;Secure policy. See https://kontent.ai/learn/tutorials/develop-apps/build-strong-foundation/set-up-preview/#a-set-up-preview-for-web-spotlight

Repro steps

  1. Set the deployed sample app's URL as a preview URL and enable web spotlight.
  2. Open web spotlight
  3. Set your projectID and submit the form.
  4. The app still doesn't open (you stay on the configuration page)

Expected behavior

The app should open the homepage route with the project id in a cookie.

Test environment

  • chrome

Restore Preview API functionality

As part of the update to the TypeScript SDK, the Preview API was taken out of the default behavior. It should be restored so that the instructions in README.md enable users to easily enable previews from the sample app.

Update integration sample - Hubspot

Brief bug description

After the rebranding from Kentico Cloud to Kentico Kontent there are still some samples that use old naming in branches named samples/*.

Until the end of October endpoint on domain kenticocloud.com stop working and there will be redirect performed:

Expected behavior

Transfer changes made in #140 to the samples/hubspot branch

  • Update dependency from kentico-cloud-delivery to @kentico/kontent-delivery
    • adjust the breaking changes
  • Update dependency @chevtek/react-spinners to @simply007org/react-spinners
    • no breaking changes
  • Rename Kentico Cloud to Kentico Kontent
  • adjust travis.yml to use the correct domain for deployment

Handle missing values in the preview

Motivation

The app crashes unexpectedly in the preview mode for articles without the image or products without the price. Preview Delivery API returns items in the draft step and some values can be missing (even required fields).

Proposed solution

  • The app should handle missing values and display some placeholder without data or with some explanation (e.g,. "Price TBA")
  • check other possible occurences of this problem

Additional context

image

Demonstrate the URL slug

Once we add relevant sample content to the sample project we'd like to update this sample app to reflect the changes and demonstrate the URL slug functionality.

Internal reference: DEL-665

Inline content modules are not loaded properly

Application does not count with the inline content module within the rich text element.

Example on coffee-beverages-explained article:
image

This change was made @jancerman (Andrew Dixon) on Jun 27, 2017 · 3:12 pm according to revision history.

Handle missing values in Preview for Metadata component

Motivation

As was described in #115, there is insufficient check for missing values for Metadata component values.

Great jop @Karl-EdwardFPJeanMehu, thanks!

Proposed solution

According to the metadata (i.e. ogImage) I would recommend using the lodash for the value check:

import _ from 'lodash';
...
      {!_.has(props, 'ogImage.value[0].url') ? null : (  // current state =>  {!props.ogImage ? null : (
        <meta property=\"og:image\" content={props.ogImage.value[0].url} />
      )}

Remove deprecated livecycle method - UNSAFE_componentWillReceiveProps

Motivation

In React v17 UNSAFE_componentWillReceiveProps method is deprecated and should be replaced by another lifecycle method.

Proposed solution

Change calling of UNSAFE_componentWillReceiveProps method to some more appropriate - some tips point to https://reactjs.org/docs/react-component.html#static-getderivedstatefromprops.
Try that one and make a testing of all occurrences.

Additional context

Support runnable templates

Similarly to kontent-ai/boilerplate-net#1, we'd like to support the new VS tooling and be able to install the site using the dotnet new command.

Ideally, the template should be parameterized with the project guid.

All necessary resources can be found in the related task.

Implement unsubscription for the stores

Stores used for providing the data from Kentico cloud are using observable collections. Stores are subscribed to the collection changes, but the subscription is not canceled when the component using this store is unmounted.

Example in /Stores/Article.js
image

We need to cancel the subscriptions, because we need to cancel the request when the component which was using the store to load the data is not rendered on the site anymore.

Update integration sample - Optimizely

Brief bug description

After the rebranding from Kentico Cloud to Kentico Kontent there are still some samples that use old naming in branches named samples/*.

Until the end of October endpoint on domain kenticocloud.com stop working and there will be redirect performed:

Expected behavior

Transfer changes made in #140 to the samples/optimizely branch

  • Update dependency from kentico-cloud-delivery to @kentico/kontent-delivery
    • adjust the breaking changes
  • Update dependency @chevtek/react-spinners to @simply007org/react-spinners
    • no breaking changes
  • Rename Kentico Cloud to Kentico Kontent
  • adjust travis.yml to use the correct domain for deployment

Hardcoded assets in app

Motivation

Currently, it's unclear at first what content is hardcoded in the app and what is drawn from Kentico Cloud. For example, the Hero unit on the homepage is not drawn from Kentico Cloud. So it's possible to run the app and get confused when changing the Hero unit in Kentico Cloud doesn't change the content in the app.

Proposed solution

  • create an account in Kentico Cloud and let it generate a sample project for you
  • search for jpg in this repo
  • replace all hardcoded assets with ones from Kentico Cloud.
    -- use the JavaScript SDK to retrieve the assets using their codenames
    -- see the docs for more details about how to work with Kentico Cloud API
  • remove replaced assets from this repository

Additional context

Make a footer part of the site as a react element

Currently footer is hardcoded in the html markup, so that it is not possible to localize its content.

We want to transform this part of the site to a react rendered part. Defined it as a component and use prepared infrastructure to translate its content.

image

Add multilingual support

Similarly to kontent-ai/sample-app-net#19, add a Spanish translation of the site.

  • Add a language switch
  • Add appropriate routing mechanism using router-react, or router-react-redux (or a similar standardized technology)
  • Add a globalization (resource) strings support (again, choose a common approach)
  • Translate globalization strings
  • Translate texts in the KC Sample Project (separate issue: #20)

Demonstrate the multiple choice element

Demonstrate the multiple choice element.

Sample Project ID: 975bf280-fd91-488c-994c-2f04416e5ee3
Content Type: Coffee
Element Name: Processing

Internal reference: DEL-680

Update integration sample - Shopify

Brief bug description

After the rebranding from Kentico Cloud to Kentico Kontent there are still some samples that use old naming in branches named samples/*.

Until the end of October endpoint on domain kenticocloud.com stop working and there will be redirect performed:

Expected behavior

Transfer changes made in #140 to the samples/shopify branch

  • Update dependency from kentico-cloud-delivery to @kentico/kontent-delivery
    • adjust the breaking changes
  • Update dependency @chevtek/react-spinners to @simply007org/react-spinners
    • no breaking changes
  • Rename Kentico Cloud to Kentico Kontent
  • adjust travis.yml to use the correct domain for deployment

Configuration admin page is not up-to-date with the latest design

Brief bug description

The Kontent design changed quite a lot since (Admin/Configuration.js)[https://github.com/Kentico/kontent-sample-app-react/blob/master/src/Pages/Admin/Configuration.js] was last updated. It should look completely different now. Check out kontent-ai/sample-app-net#128 for an inspiration.

Repro steps

  1. Clone repository fresh (or clearn up projectID)
  2. Run the app
  3. See the configuration in the old design:
    image

Expected behavior

The configuration should now look like this:
image

Update integration sample - Magento

Brief bug description

After the rebranding from Kentico Cloud to Kentico Kontent there are still some samples that use old naming in branches named samples/*.

Until the end of October endpoint on domain kenticocloud.com stop working and there will be redirect performed:

Expected behavior

Transfer changes made in #140 to the samples/magento branch

  • Update dependency from kentico-cloud-delivery to @kentico/kontent-delivery
    • adjust the breaking changes
  • Update dependency @chevtek/react-spinners to @simply007org/react-spinners
    • no breaking changes
  • Rename Kentico Cloud to Kentico Kontent
  • adjust travis.yml to use the correct domain for deployment

Update integration sample - Bynder

Brief bug description

After the rebranding from Kentico Cloud to Kentico Kontent there are still some samples that use old naming in branches named samples/*.

Until the end of October endpoint on domain kenticocloud.com stop working and there will be redirect performed:

Expected behavior

Transfer changes made in #140 to the samples/bynder branch

  • Update dependency from kentico-cloud-delivery to @kentico/kontent-delivery
    • adjust the breaking changes
  • Update dependency @chevtek/react-spinners to @simply007org/react-spinners
    • no breaking changes
  • Rename Kentico Cloud to Kentico Kontent
  • adjust travis.yml to use the correct domain for deployment

Add Preview Edit Links

Kentico Kontent admin UI now supports navigating to specific content items via URLs in a certain format.

The goal of this task is to enrich the markup of this sample application with the links.

Suggested approach:

Blocked by: https://github.com/Kentico/kontent-delivery-sdk-js/issues/52

Motivation

We want to present to our customers an example of this feature – how they can use that

Solution

When
I open About Us preview
Then
I see enabled "Edit mode" in the fixed bar on the bottom of the page
And
I am able to click on each element from the page About Us

When
I open About Us preview
Then
I see the link "Open in KC" in the fixed bar on the bottom of the page
And
I am able to click on it

When
I click on toggle button Edit mode
Then
Edit mode is turned off
And
I am able to preview page without distraction - only the fixed bar is presented

Design notes

  • Do not show button for menu/navigation,Language selector, Dancing goat heading
  • For Text element – show edit button next to the element (on the right)
  • For Richt text element (and others) – show edit button in the center of the element
  • While in Edit mode, I am able to click anywhere on the element (not just on the button) to be redirected to KC
  • When I hover over the element, the button should be in hover state

Add a loading indicator

The application should show a loading indicator (loading spinner) when waiting for data from Kentico Cloud.

Replace hardcoded sample project items count in SelectedProject.js

Motivation

In /src/Utilities/SelectedProject.js there is a hardcoded SAMPLE_PROJECT_ITEM_COUNT constant which is used in the wizard.

This wizard checks if the Delivery API has already accessible all items in the user's Dancing Goat project and if the project is fully accessible. If the count of all items in the project is more or equals to items from constant then we consider the project to be ready.

However, if the user's sample Dancing Goat project changes (we add/remove new content) this logic might not work. Under the hood, we clone the Dancing Goat project from 'one-source-of-truth' project.

Proposed solution

The goal of this issue is to implement logic which will get a count of items in from this source (-of-truth) project (projectId: 975bf280-fd91-488c-994c-2f04416e5ee3) and store it to an existing (non)constant which will be checked the same way as it is right now.

Note: It might be a good idea to adjust if condition in Configuration.js, too.
Something like ... if (response.items.length > SAMPLE_PROJECT_ITEM_COUNT) in waitUntilProjectAccessible function.

Update integration sample - GA experiments

Brief bug description

After the rebranding from Kentico Cloud to Kentico Kontent there are still some samples that use old naming in branches named samples/*.

Until the end of October endpoint on domain kenticocloud.com stop working and there will be redirect performed:

Expected behavior

Transfer changes made in #140 to the samples/ga-experiments branch

  • Update dependency from kentico-cloud-delivery to @kentico/kontent-delivery
    • adjust the breaking changes
  • Update dependency @chevtek/react-spinners to @simply007org/react-spinners
    • no breaking changes
  • Rename Kentico Cloud to Kentico Kontent
  • adjust travis.yml to use the correct domain for deployment

google-maps-react is not supported in React 17

Brief bug description

google-maps-react is not supported in React 17

Repro steps

  1. Remove node_modules and package-lock.json
  2. Run npm i

Error:

ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: [email protected]
npm WARN node_modules/react
npm WARN   react@"^17.0.2" from the root project
npm WARN   9 more (@simply007org/kontent-react-components, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"~0.14.8 || ^15.0.0 || ^16.0.0" from [email protected]
npm WARN node_modules/google-maps-react
npm WARN   google-maps-react@"^2.0.6" from the root project
npm WARN
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/react
npm WARN   peer react@"~0.14.8 || ^15.0.0 || ^16.0.0" from [email protected]
npm WARN   node_modules/google-maps-react
npm WARN     google-maps-react@"^2.0.6" from the root project
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: [email protected]
npm WARN node_modules/react-dom
npm WARN   react-dom@"^17.0.2" from the root project
npm WARN   2 more (@simply007org/kontent-react-components, react-scroll)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react-dom@"~0.14.8 || ^15.0.0 || ^16.0.0" from [email protected]
npm WARN node_modules/google-maps-react
npm WARN   google-maps-react@"^2.0.6" from the root project
npm WARN 
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/react-dom
npm WARN   peer react-dom@"~0.14.8 || ^15.0.0 || ^16.0.0" from [email protected]
npm WARN   node_modules/google-maps-react
npm WARN     google-maps-react@"^2.0.6" from the root project

Expected behavior

No error - try to find an alternative package for the Google Maps component.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.