Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/migration #208

Merged
merged 28 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
run: cp .env.sample .env

- name: Build UI ${{ matrix.node-version }}
working-directory: packages/ui
working-directory: packages/shared-ui
run: pnpm build

- name: "Storybook: Install Extra Dependencies"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
${{ runner.os }}-cypress-store-

- name: Build UI ${{ matrix.node-version }}
working-directory: packages/ui
working-directory: packages/shared-ui
run: pnpm build

- name: Cypress Run (Production Backend)
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/components/CartItem.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from "react";
import { IoMdClose } from "react-icons/io";
import { Input } from "shared-ui";
import { currencyFormatter } from "utils/currencyFormatter";
import { CartItem as CartItemType, useCart } from "./CartContext";
import { Input } from "./Input";

type CartItemProps = {
item: CartItemType;
Expand Down
4 changes: 1 addition & 3 deletions packages/nextjs/components/Footer/EmailSubscribe.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { FaChevronRight } from "react-icons/fa";
import { Input } from "components/Input";
import { H3 } from "components/Typography/H3";
import { LinkText } from "components/LinkText";
import { H3, Input, LinkText } from "shared-ui";

export const EmailSubscribe = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/components/Footer/FooterLinks.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LinkText } from "components/LinkText";
import { LinkText } from "shared-ui";

export const FooterLinks = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/components/Product.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Link from "next/link";
import { Price } from "shared-ui";
import { PLPVariant } from "utils/groqTypes/ProductList";
import { Image } from "./Image";
import { Price } from "./Price";

type Props = {
item: PLPVariant;
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/components/ProductFilters/FilterGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { FilterGroup as FilterGroupType } from "utils/filters";
import * as React from "react";
import { ChangeEvent } from "react";
import { Checkbox } from "shared-ui";
import { useRouterQueryParams } from "utils/useRouterQueryParams";
import { Checkbox } from "components/Checkbox";

type FilterGroupProps = {
group: FilterGroupType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from "react";
import { useMemo } from "react";
import { Select } from "components/Select";
import { H6 } from "components/Typography/H6";
import { H6, Select } from "shared-ui";
import { Variant } from "utils/groqTypes/ProductList";

interface Props {
Expand Down
3 changes: 1 addition & 2 deletions packages/nextjs/components/ProductPage/StyleOptions.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from "react";
import { Pill } from "components/Pill";
import { H6 } from "components/Typography/H6";
import { H6, Pill } from "shared-ui";
import { Style } from "utils/groqTypes/ProductList";

interface Props {
Expand Down
3 changes: 1 addition & 2 deletions packages/nextjs/components/ProductSort.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import * as React from "react";
import { Pill, Select } from "shared-ui";
import { PAGE_QUERY_PARAM, SORT_OPTIONS, SORT_OPTIONS_ARRAY, SORT_QUERY_PARAM, SortType } from "utils/sorting";
import { useRouterQueryParams } from "utils/useRouterQueryParams";
import { Pill } from "./Pill";
import { Select } from "./Select";

type ProductSortProps = {
as?: "select" | "pills";
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { useCallback, useEffect, useMemo, useReducer } from "react";
import debounce from "lodash.debounce";
import Link from "next/link";
import { q, sanityImage, TypeFromSelection } from "groqd";
import { Input } from "shared-ui";
import { runQuery } from "utils/sanityClient";
import { Image } from "./Image";
import { Input } from "./Input";

type State = {
results: ProductSearch[];
Expand Down
2 changes: 0 additions & 2 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
"test:storybook:start": "start-server-and-test 'pnpm run storybook:start' 6006 'pnpm run test:storybook'"
},
"dependencies": {
"@headlessui/react": "^1.7.8",
"@portabletext/react": "^1.0.6",
"@sanity/client": "^3.3.6",
"@sanity/dashboard": "^3.1.3",
"@sanity/image-url": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import * as React from "react";
import Head from "next/head";
import { AnimatePresence, MotionConfig } from "framer-motion";

import { FadeInOut } from "shared-ui";
import { CartProvider } from "components/CartContext";
import { Layout } from "components/Layout";
import "styles/global.css";
import { FadeInOut } from "components/FadeInOut";

(async () => {
if (process.env.NEXT_PUBLIC_API_MOCKING === "enabled") {
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/pages/about.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { NextPage } from "next";
import NextImage from "next/legacy/image";

import Link from "next/link";
import { BreadIcon } from "shared-ui";
import { localImageLoader } from "utils/localImageLoader";
import { BreadIcon } from "components/Bread.icon";
import { PageHead } from "components/PageHead";
import { Breadcrumbs } from "components/Breadcrumbs";

Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/pages/categories.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { GetServerSideProps, NextPage } from "next";

import { WeDontSellBreadBanner } from "shared-ui";
import { setCachingHeaders } from "utils/setCachingHeaders";
import { SanityType } from "utils/consts";
import { isString, pluralize } from "utils/pluralize";
import { getAllCategories } from "utils/getAllCategoriesQuery";

import { CategoryList } from "components/CategoryList";
import { WeDontSellBreadBanner } from "components/WeDontSellBreadBanner";
import { PageHead } from "components/PageHead";
import { Breadcrumbs } from "components/Breadcrumbs";
import { Category } from "utils/groqTypes/ProductList";
Expand Down
7 changes: 1 addition & 6 deletions packages/nextjs/pages/components.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { MdArrowForward } from "react-icons/md";
import { Button } from "shared-ui";
import { Checkbox } from "components/Checkbox";
import { Input } from "components/Input";
import { LinkText } from "components/LinkText";
import { Pill } from "components/Pill";
import { Select } from "components/Select";
import { Button, Input, Pill, Checkbox, Select, LinkText } from "shared-ui";

export default function ComponentsPage() {
return (
Expand Down
3 changes: 1 addition & 2 deletions packages/nextjs/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FiArrowRight } from "react-icons/fi";
import Link from "next/link";
import NextImage from "next/legacy/image";

import { Button } from "shared-ui";
import { Button, FeaturedQuote } from "shared-ui";
import { setCachingHeaders } from "utils/setCachingHeaders";
import { localImageLoader } from "utils/localImageLoader";
import { SanityType } from "utils/consts";
Expand All @@ -14,7 +14,6 @@ import { getRecommendations } from "utils/getRecommendationsQuery";

import featuredImg from "assets/featured-story.jpg";
import { FeaturedList } from "components/FeaturedList";
import { FeaturedQuote } from "components/FeaturedQuote";
import { Image } from "components/Image";
import { PageHead } from "components/PageHead";

Expand Down
6 changes: 1 addition & 5 deletions packages/nextjs/pages/products/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,19 @@ import { GetServerSideProps, NextPage } from "next";
import { useRouter } from "next/router";
import { AnimatePresence } from "framer-motion";

import { H6, FadeInOut, BlockContent, Price, QuantityInput } from "shared-ui";
import { setCachingHeaders } from "utils/setCachingHeaders";
import { isSlug } from "utils/isSlug";
import { SanityType } from "utils/consts";
import { getRecommendations } from "utils/getRecommendationsQuery";
import { getProductBySlug } from "utils/getProductBySlug";

import { BlockContent } from "components/BlockContent";
import { ImageCarousel } from "components/ImageCarousel";
import { useCart } from "components/CartContext";
import { PageHead } from "components/PageHead";
import { Price } from "components/Price";
import { QuantityInput } from "components/ProductPage/QuantityInput";
import { StyleOptions } from "components/ProductPage/StyleOptions";
import { ProductVariantSelector } from "components/ProductPage/ProductVariantSelector";
import { H6 } from "components/Typography/H6";
import { Product } from "components/Product";
import { FadeInOut } from "components/FadeInOut";
import { Breadcrumbs } from "components/Breadcrumbs";

interface PageProps {
Expand Down
4 changes: 1 addition & 3 deletions packages/nextjs/pages/products/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AnimatePresence } from "framer-motion";
import { useRouter } from "next/router";
import classNames from "classnames";

import { H6, WeDontSellBreadBanner, FadeInOut } from "shared-ui";
import { getAllFilteredVariants } from "utils/getFilteredPaginatedQuery";
import { getCategoryFilters, getFlavourFilters, getStyleFilters } from "utils/getFilters";
import { getPaginationFromQuery } from "utils/getPaginationFromQuery";
Expand All @@ -16,13 +17,10 @@ import { CategoryFilterItem, FlavourFilterItem, PLPVariant, StyleFilterItem } fr
import { useDeviceSize } from "utils/useDeviceSize";

import { PageHead } from "components/PageHead";
import { WeDontSellBreadBanner } from "components/WeDontSellBreadBanner";
import { ProductSort } from "components/ProductSort";
import { ProductFilters } from "components/ProductFilters/ProductFilters";
import { Product } from "components/Product";
import { H6 } from "components/Typography/H6";
import { Pagination } from "components/Pagination";
import { FadeInOut } from "components/FadeInOut";
import { Breadcrumbs } from "components/Breadcrumbs/Breadcrumbs";
import { ModalFiltersMobile } from "views/ModalFiltersMobile";
import { SortAndFiltersToolbarMobile } from "views/SortAndFiltersToolbarMobile";
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
"./pages/**/*.{js,jsx,ts,tsx}",
"./components/**/*.{js,jsx,ts,tsx}",
"./views/**/*.{js,jsx,ts,tsx}",
"../ui/components/**/*.{js,jsx,ts,tsx}",
"../shared-ui/components/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {
Expand Down
3 changes: 1 addition & 2 deletions packages/nextjs/views/ModalFiltersMobile.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Button } from "shared-ui";
import { Button, Modal } from "shared-ui";
import React from "react";
import { Modal } from "components/Modal";
import { ProductFilters } from "components/ProductFilters/ProductFilters";
import { CategoryFilterItem, FlavourFilterItem, StyleFilterItem } from "utils/groqTypes/ProductList";

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as React from "react";

type BreadIconProps = {
size?: number;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const Pill: React.FC<Props> = ({ disabled, className, selected, children,
<button
disabled={disabled}
className={classNames(
"border text-body-sm rounded-full py-2 px-4 hover:bg-primary hover:text-sky transition transition-colors duration-150",
"border text-body-sm rounded-full py-2 px-4 hover:bg-primary hover:text-sky transition-colors duration-150",
{
"text-primary": !selected,
"bg-primary text-sky": selected,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import { Eyebrow } from "components/Typography/Eyebrow";
import { currencyFormatter } from "utils/currencyFormatter";
import { Eyebrow } from "./Typography";
import { currencyFormatter } from "../uitls/currencyFormatter";

interface Props {
msrp?: number | null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FiPlus } from "react-icons/fi";
import { Button } from "shared-ui";
import { Input } from "components/Input";
import { H6 } from "components/Typography/H6";
import { Button } from "./Button/Button";
import { H6 } from "./Typography";
import { Input } from "./Input";

interface Props {
quantity: string;
Expand Down
3 changes: 3 additions & 0 deletions packages/shared-ui/components/Typography/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./Eyebrow";
export * from "./H3";
export * from "./H6";
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as React from "react";

export const WeDontSellBreadBanner = () => {
return (
<div className="p-2 bg-primary">
Expand Down
1 change: 1 addition & 0 deletions packages/shared-ui/components/sanity/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./BlockContent";
16 changes: 16 additions & 0 deletions packages/shared-ui/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export * from "./components/Button/Button";
export * from "./components/Typography";
export * from "./components/Input";
export * from "./components/Pill";
export * from "./components/Checkbox";
export * from "./components/Bread.icon";
export * from "./components/FeaturedQuote";
export * from "./components/FadeInOut";
export * from "./components/Select";
export * from "./components/LinkText";
export * from "./components/Modal";
export * from "./components/WeDontSellBreadBanner";
export * from "./components/Price";
export * from "./components/QuantityInput";

export * from "./components/sanity";
6 changes: 5 additions & 1 deletion packages/ui/package.json → packages/shared-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
"test:storybook:start": "start-server-and-test 'pnpm run storybook:start' 6006 'pnpm run test:storybook'"
},
"dependencies": {
"@headlessui/react": "^1.7.8",
"@portabletext/react": "^1.0.6",
"@tailwindcss/typography": "^0.5.4",
"classnames": "^2.3.2",
"framer-motion": "^7.4.0"
"framer-motion": "^7.4.0",
"downshift": "^6.1.9",
"react-icons": "^4.4.0"
},
"peerDependencies": {
"react": ">=18.0.0",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions packages/shared-ui/uitls/currencyFormatter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const currencyFormatter = Intl.NumberFormat("en-US", { style: "currency", currency: "USD" });
1 change: 0 additions & 1 deletion packages/ui/index.ts

This file was deleted.

Loading
Loading