Giter Site home page Giter Site logo

carbon-for-ibm-dotcom-nextjs-template's Introduction

Carbon for IBM.com React with Next.js Template

Table of Contents

Overview

This is a Next.js template utilizing Carbon for IBM.com React, deploying a vanilla instance of Next.js with the DotcomShell, along with other various patterns and components available in Carbon for IBM.com.

Getting Started

Get the code by cloning this repo using git

git clone https://github.com/carbon-design-system/carbon-for-ibm-dotcom-nextjs-template.git

Once cloned, go to the project directory to install dependencies and build the project

$ yarn && yarn build

In order to enable features like Right-to-Left (RTL), you will have to set environment variables in a .env file. Please see .env.example.

BASE_PATH=<Sets the base directory for urls and assets, default is '' >
ALTLANG_ROOT_PATH=<Sets the root path for language alternative urls, default is '/' >
ENABLE_RTL=<Boolean to enable RTL for the page, eg. false >
SASS_PATH=node_modules:src

Then start the application:

$ yarn dev

To export to a static site, run the following:

$ yarn build-export

Then the contents of the out folder can be uploaded to your production environment.

SASS compilation and carbon-components

There may be times pathing errors are encountered when importing certain stylesheets (like carbon-components). We're working hard to fix these, but in the meantime you can add the following to your .env file to resolve:

SASS_PATH=node_modules:src

Note: For Windows, the syntax is slightly different

SASS_PATH=./node_modules;./src

Right-to-Left (RTL)

Right-to-left rendering is supported, to enable set the ENABLE_RTL environment variable to true.

Things to Note

If building an IBM.com page, there are items that need to be included which can be viewed here: Building for IBM.com

Page Language

This template handles page language functionality, where the available languages are defined in components/data/altlang.json. The Altlangs component then generates all alternate links to be injected into the <head> element.

Digital Data Object

The Digital Data Object (DDO) is a flexible, customizable collection of metadata that also provides tools and services such as live chat and analytics to page authors. You can find more details on Building for IBM.com.

The template has a placeholder DDO you can define located in `pages/data/DDO.json. Example values shown below:

<script>
  digitalData = {
    page: {
        category: {
            primaryCategory: '' // e.g. SB03
        },
        pageInfo: {
            effectiveDate: '', // e.g. 2014-11-19
            expiryDate: '', // e.g. 2017-11-19
            language: '', // e.g. en-US
            publishDate: '', // e.g. 2014-11-19
            publisher: '', // e.g. IBM Corporation
            version: 'Carbon for IBM.com',
            ibm: {
                contentDelivery: '', // e.g. ECM/Filegen
                contentProducer: '', // e.g. ECM/IConS Adopter 34 - GS83J2343G3H3ERG - 11/19/2014 05:14:02 PM
                country: '', // e.g. US
                industry: '', // e.g. B,U
                owner: '', // e.g. Some Person/City/IBM
                siteID: '', // e.g. MySiteID
                subject: '', // e.g. SW492
                type: '' // e.g CT305
            }
        }
    }
  };
</script>

Meta Tags and Analytics

The template already renders the required meta tags and IBM.com analytics script that are required for IBM.com websites. They are located in pages/_app.js.These can be adjusted/removed to fit your project and needs.

Meta Tags:

<meta charset="UTF-8" />

<link rel="icon" href="//www.ibm.com/favicon.ico" />

<meta name="dcterms.date" content="YYYY-MM-DD" />
<meta name="dcterms.rights" content="© Copyright IBM Corp. 2016" />
<meta name="geo.country" content="US" />
<meta name="robots" content="index,follow" />

IBM.com Tag Management and Site Analytics Script

<!-- IBM Tag Management and Site Analytics -->
<script src="//1.www.s81c.com/common/stats/ibm-common.js" defer></script>

Upgrading from the Template

To pull latest changes from the Carbon for IBM.com NextJS template, this repo can be added as a remote to your application repository:

git remote add template https://github.com/carbon-design-system/carbon-for-ibm-dotcom-nextjs-template.git

Then run git fetch to update the changes:

git fetch --all

And finally merge changes in:

git merge template/main

carbon-for-ibm-dotcom-nextjs-template's People

Contributors

annawen1 avatar ariellalgilmore avatar dependabot[bot] avatar guilhermelmoraes avatar ibmdotcom-bot avatar ignaciobecerra avatar jeffchew avatar kelvinelove avatar kennylam avatar mstudio avatar raphaelamadeu-zz avatar renovate[bot] 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

Watchers

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

carbon-for-ibm-dotcom-nextjs-template's Issues

Add a '.nvmrc' file and specify appropriate Node's version

The problem

All,

I got this message when trying to install dependencies required to run this template repo:
The engine "node" is incompatible with this module. Expected version ">=12 <14". Got "17.0.0"

Naturally, I figured I was using a newer version of Node than what is required to build from source, which has, in my opinion, an easy and intuitive fix: NVM (Node Version Manager).

The solution

More specifically, if we were to include a '.nvmrc' file and specify Node's appropriate versioning along with it, it could potentially improve the project's experience, as far as development is concerned. For example:
e1wdw

Application/website

https://github.com/nvm-sh/nvm#deeper-shell-integration

Business priority

Low Priority = release date is not dependent on fix or not upcoming

What time frame would this ideally be needed by (if applicable)

No response

Examples

See above.

Code of Conduct

[Card section simple] NextJS Learn template styles issue on card hover

Title line template: [Title]: Brief description

Detailed description

Card hover style is incorrect in the NextJS Card section component.

image

Is this a feature request (new component, new icon), a bug, or a general
issue?
Bug

Is this issue related to a specific component?
Card section

What did you expect to happen? What happened instead? What would you like to
see changed?
Hover state has incorrect styles

What browser are you working in?

What version of the NextJS template are you using?

What offering/product do you work on? Any pressing ship or release dates we
should be aware of?

http://think2021.eu-de.mybluemix.net/

Country selector in footer does not show all altlang entries

The country selector only shows a subset of the cc-lc entries in altlang.json.

Detailed description

This is my altlang.json
[ { "lc": "fr", "cc": "fr" }, { "lc": "en", "cc": "cz" }, { "lc": "de", "cc": "at" }, { "lc": "de", "cc": "ch" }, { "lc": "de", "cc": "de" }, { "lc": "en", "cc": "dk" }, { "lc": "en", "cc": "ie" }, { "lc": "es", "cc": "es" }, { "lc": "pl", "cc": "pl" }, { "lc": "it", "cc": "it" }, { "lc": "en", "cc": "no" }, { "lc": "en", "cc": "se" }, { "lc": "en", "cc": "fi" }, { "lc": "en", "cc": "be" }, { "lc": "en", "cc": "nl" }, { "lc": "en", "cc": "gb" } ]

It does show the first 9 entries on the web page, in the footer country selector, but ignores the others. Seems like it 'breaks' at some point in the list. If I insert a new proper entry inbetween, it could be that it is shown as well, but could also be breaking at that step then.

Is this a feature request (new component, new icon), a bug, or a general
issue?

Probably a bug

Is this issue related to a specific component?

Yes, Footer --> country selector

What did you expect to happen? What happened instead? What would you like to
see changed?

Expected to see all country / language combinations available, at least where cc and lc have reasonable values.

What browser are you working in?

FF / Chrome latest

What version of the NextJS template are you using?

Not sure, I don't see any version numbering... we started in July though, and using e.g. @carbon/ibmdotcom-react": "^1.11.0

What offering/product do you work on? Any pressing ship or release dates we
should be aware of?

Storage Digital Platform - this is already live and having quite some attention. This is a smaller annoying bug. Doesn't break, but makes switching between locales quite difficult here and there.

Steps to reproduce the issue

  1. Go e.g. here https://wwwstage.ibm.com/it-infrastructure/storage/flash/offers/uk-en
  2. Enter user name and password if prompted (enter once, then hit cancel)
  3. Scroll to bottom, click on 'United Kingdom - English' in the footer country selector. Click on Europe
  4. Note that it contains less entries than my list above.

Dynamic routing bug

When utilising dynamic routing, the page renders but an error is thrown upon first navigation to dynamic route:
Screenshot 2020-07-28 at 11 46 44

Upon refresh, the page does not render and an error is displayed:
Screenshot 2020-07-28 at 11 47 41

SOLUTION

inside of the next.config.js, inside of the module.exports there is a key value pair called assetPrefix. By removing this from the withCSS, the errors ceased and the dynamic routing worked flawlessly.

References:
https://stackoverflow.com/questions/52195494/next-js-next-webpack-hmr-request-404

[NextJS Template] Investigate upgrade to NextJS 11

The problem

More users may be interested in taking advantage of the latest version of NextJS when starting a new project with Carbon for IBM.com. It was just announced that NextJS 11 has been released:

https://nextjs.org/blog/next-11

The solution

Upgrade the NextJS template to v11

Additional information

Tag Management Script is loaded twice

Detailed description

When working with the Next.JS Template and including the <script src="//1.www.s81c.com/common/stats/ibm-common.js" defer></script> the script is loaded twice due to an existing Next.js issue: vercel/next.js#9070

Is this a feature request (new component, new icon), a bug, or a general
issue?
Bug

Is this issue related to a specific component?
No

What did you expect to happen? What happened instead? What would you like to
see changed?
The script should only be loaded once and there shouldn't be an error in dev environment.

What browser are you working in?
Firefox, Chrome, Safari

What version of the NextJS template are you using?
9.5.5

What offering/product do you work on? Any pressing ship or release dates we
should be aware of?
IBM CHQ Events // DACH

Steps to reproduce the issue

  1. Open a Website using Next.js (e.g. Think)
  2. Open the console
  3. See the errors

Additional information

Screenshot 2021-03-17 at 17 53 52
Screenshot 2021-03-17 at 17 54 22
Screenshot 2021-03-17 at 17 54 31

[NextJS]: on white and gray 100 multiple cards are missing links

Description

white theme:
Card section carousel cards are missing links
Screen Shot 2022-02-15 at 4 20 21 PM

Gray 100:
Leadspace jump does not jump to anywhere
Screen Shot 2022-02-15 at 4 21 14 PM
Card in card missing link
Screen Shot 2022-02-15 at 4 21 54 PM
Card section carousel cards are missing links

Screen Shot 2022-02-15 at 4 22 15 PM

Example page b:
CardLink should not have blue heading
Screen Shot 2022-02-15 at 4 23 45 PM

Component(s) impacted

Card section carousel (cards)
Leadspace buttons
Card in card
CardLink

Browser

Chrome

Carbon for IBM.com version

1.31.0-rc.1

Severity

Severity 3 = The problem is visible or noticeable to users but does not impede the usability or functionality. Affects minor functionality, has a workaround.

Application/website

Carbon for ibm.com

Package

@carbon/ibmdotcom-react

CodeSandbox example

https://carbon-design-system.github.io/carbon-for-ibm-dotcom-nextjs-test/next/

Steps to reproduce the issue (if applicable)

  1. https://carbon-design-system.github.io/carbon-for-ibm-dotcom-nextjs-test/next/
  2. go to page b, white, and grey 100 pages

Release date (if applicable)

No response

Code of Conduct

Unhandled Runtime Error

Detailed description

Describe in detail the issue you're having.
When running yarn dev on the un-modified repo and going to the localhost route I receive an error. See Additional information. Error seems to be from by axios.

I am using google chrome and I believe I am on the latest version of the template (I have pulled the latest version and yarn upgraded incase that helped)

Steps to reproduce the issue

  1. clone the repo
  2. yarn
  3. yarn dev
  4. go to http://localhost:3000
  5. unhandled runtime error

Additional information

Screenshot 2021-01-28 at 09 02 44

[NextJS Template] Move digitalData declaration to _document.js

Detailed description

Describe in detail the issue you're having.

A race condition was brought up in the following blog article:
https://w3.ibm.com/w3publisher/geds/engineering-blog/8a5af580-b412-11eb-ac39-b90ee91bc6c6

Essentially, the digitalData object is getting set in some cases which overrides what is being set by IBM common library. The fix is to move the declaration to _document.js.

Is this a feature request (new component, new icon), a bug, or a general
issue?

Bug

Is this issue related to a specific component?

digitalData object (from ibm-common.js)

What did you expect to happen? What happened instead? What would you like to
see changed?

Move the digitalData declaration to _document.js.

[Carousel] react wrapper - not loading properly on page load

Detailed description

Describe in detail the issue you're having.
On page load, the styling for the Carousel component takes a couple seconds to load.

Is this a feature request (new component, new icon), a bug, or a general
issue?
This is a bug.

Is this issue related to a specific component?
Yes, to the Carousel component from 'Carbon for IBM.com Web Components with React'. https://ibmdotcom-web-components-react.mybluemix.net/?path=/story/components-carousel--default

What did you expect to happen? What happened instead? What would you like to
see changed?
I expected that the component would load properly once page is loaded, but what happens is that its styling does not load for a couple of seconds. I would like to see its styling fully loading.

What browser are you working in?
Google Chrome Version 90.0.4430.212

What version of the NextJS template are you using?
10.1.3

What offering/product do you work on? Any pressing ship or release dates we
should be aware of?
In this case, I'm working on ibm.com/events. No release dates.

Steps to reproduce the issue

  1. Step one
    Include Carousel component on a project using NextJS template.

  2. Step two
    Run yarn build-export to generate build files.

  3. Step three
    Upload build files to testing/production environment.

Additional information

  • Screenshots or code
cssload.mov
  • Notes
    This issue only seems to happen when I upload the build files to wwwpreview or wwwstage. On localhost it seems to be working properly. The issue can be seen on this wwwpreview page: https://wwwpreview.ibm.com/events/

[CTASection]: passing Onclick to the cta does not work

Detailed description

I'm trying to use the CTA Section component, with CTA as a button. The buttons work properly except for the onClick property, that seems to be ignored. This is how I'm calling the component:

<CTASection {...props.contentBlockProps} cta={{ style: "button", type: "local", buttons: [{ type: "local", copy: "CTA 1", onClick: () => console.log(true) }] }} />

https://www.ibm.com/standards/carbon/react/?path=/story/components-cta-section--default

I used a similar approach in the LeadSpace component and it works fine.
Could you help me figured out this issue, please?

Inspecting the CTASection component code, on the "@carbon/ibmdotcom-react" package, seems that the prop type for "onClick" is not there

General

CTA Section component

The onClick should work as on the cta on leadspace

Google Chrome

Upgrade project to use Node 18

The problem

The project currently supports Node versions 14 and 16. Version 14 has already reached EOL and 16 will be EOL in 9/23.

The solution

The project should be updated to use at minimum Node 18.

Application/website

Carbon for IBM.com

Business priority

High Priority = pressing release

What time frame would this ideally be needed by (if applicable)

No response

Examples

No response

Code of Conduct

[Card in card] Transition animation bug

Detailed description

Describe in detail the issue you're having.
Card in Card Transition is different. The Image does have the correct transition and the card in the card (text card) does not have a transition.

Is this a feature request (new component, new icon), a bug, or a general
issue?
Bug

Is this issue related to a specific component?
http://ibmdotcom-web-components.mybluemix.net/?path=/story/components-card-in-card--default

What did you expect to happen? What happened instead? What would you like to
see changed?
http://ibmdotcom-web-components.mybluemix.net/?path=/story/components-card-in-card--default should have a transition in the text card: transition: 150ms cubic-bezier(0.2, 0, 0.38, 0.9);

What browser are you working in?
Firefox latest version

What version of the NextJS template are you using?

What offering/product do you work on? Any pressing ship or release dates we
should be aware of?

Steps to reproduce the issue

  1. Step one
    Go to card in card section in storybook
  2. Step two
    Hover
  3. Step three
    See the glitch
  4. etc.

Expecting (Updated Jun 25 by Shixie)

Card in card's hover animation should follow the following spec:

White & Gray 10 themes Gray 90 and Gray 100 themes
darken: 8% lighten: 8%

Transition easing & duration should match the current text portion background change:

image.png

Blocker - Cannot run build on NextJS template

I want to deploy my application (uses a NextJs template) but I am getting this error:
image
(using yarn build-export)

I tried to deploy the template itself (without any updates by me) and I am getting the same error:
image
(using npm run build)

Update nextjs to 10.0.5 or above

The problem

While trying to use a nextjs feature (with the version configured on this template) which allows applications to override the base path, it works on development mode but when trying on production mode it does not.

I found this issue vercel/next.js#20097 and they mentioned it was fixed in a more recent version so I updated to 10.0.5 (not the latest) and found out indeed the issue is resolved.

The solution

Please update your template to support a more recent version of next.js.

i18n support

Hi, thanks for the template!
we want to build a site for ibm.com using this template. But one question i have is how to support different locales with static export.

if i clone this template and run yarn build-export it generates a single index.html file. Is there any recommendation on how to add i18n to the site?

I would really like to use a static export to host the site as we want to communicate against a REST API, but if not possible i think it would also be ok to run a nodejs instance.

I haven't found anything regarding i18n in the official next.js documentation.

Thanks,
Alex

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • @carbon/ibmdotcom-react ^1.44.0
  • @carbon/ibmdotcom-styles ^1.44.0
  • @carbon/icons-react ^10.9.1
  • @carbon/pictograms-react ^11.0.0
  • @babel/core ^7.18.2
  • @commitlint/cli ^17.6.3
  • @commitlint/config-conventional ^17.6.3
  • babel-preset-carbon ^0.0.14
  • cross-env 7.0.3
  • dotenv 10.0.0
  • eslint ^8.0.0
  • eslint-config-carbon ^3.3.0
  • express ^4.17.1
  • husky ^7.0.0
  • lint-staged ^13.0.3
  • next ^12.3.4
  • next-compose-plugins ^2.2.1
  • prettier ^2.0.4
  • prop-types ^15.7.2
  • react 17.0.2
  • react-dom 17.0.2
  • rtlcss ^2.6.2
  • sass ^1.62.1
  • stylelint ^14.3.0
  • stylelint-config-carbon ^1.12.0
  • node >=18
  • yarn 3.5.1

  • Check this box to trigger a request for Renovate to run again on this repository

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.