1.0.17 • Published 4 years ago

@emergy/components-navigation v1.0.17

Weekly downloads
16
License
MIT
Repository
-
Last release
4 years ago

components-navigation

Introduction

Create a basic and customizable header

Install

yarn add components-navigation

Usage

import * as React from "react";
import { useTranslation } from "@emergy/components-translations";
import { Navigation, Footer } from "@emergy/components-navigation";
import { withRouter } from "next/router";

const Layout: React.FC = () => {
  const headerLinks = [
    { href: "/about", value: "About" },
    { href: "/contact", value: "Contact" }
  ];

  const footerLinks = {
    section1: [
      { href: "/contact", value: t("contact") },
      { href: "/privacy", value: t("privacy") }
  ];

  const websiteUrl = "emergy.cc";
  return (
    <div>
      <Navigation title="Emergy" links={headerLinks} withRouter={withRouter} />
      <Footer links={footerLinks} websiteUrl={websiteUrl}>
    </div>
  );
};

export default Layout;

Usage with translation

import * as React from "react";
import { useTranslation } from "@emergy/components-translations";
import { Navigation } from "@emergy/components-navigation";
import { withRouter } from "next/router";

const Layout: React.FC = () => {
  const headerLinks = [
    { href: "/about", value: t("about") },
    { href: "/contact", value: t("contact") }
  ];
  return (
    <div>
      <Navigation title="Emergy" links={headerLinks} withRouter={withRouter} />
    </div>
  );
};

export default Layout;

Using module CSS

Scss:

// styles.scss
@import "../node_modules/@emergy/components-navigation/dist/index.es.css";

Using PurgeCSS

const CpntNav = require("next-optimized-images");
const purgeCssWhiteList = [].concat(CpntNav.purgeCss); // To activate mobile headers

// next.config.js
const purgeCssPaths = [
  "pages/**/*",
  "components/**/*",
  "node_modules/@emergy/components-navigation/dist/**/*",
];

withPurgeCss({
  purgeCssPaths,
  purgeCss: {
    whitelist: () => purgeCssWhiteList,
  },
  ...
});

Test

Basic test are created and executed for each build.
The test with enzyme doesn't work properly yet.

More details

In order to make it work properly, I had to link the project who's using the components-translations to the components-navigation:

# In the root folder of my project
cd node_modules/@emergy/components-translation
yarn link

cd <components-navigation-root-path>
yarn link "@emergy/components-translations"

License

MIT © mlescaudron

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.0

4 years ago