Skip to content

Commit c5cc132

Browse files
authored
feat: add TailwindCSS (Shopify#13)
## Context Added TailwindCSS to Hydrogen ## Changes Add `tailwind.config.ts` ## Paperwork [SCH-10](https://codeinternetapplications.atlassian.net/browse/SCH-10) ## Checklist - [x] My code follows the style guidelines of this project - [x] I've performed a self-review of my own code - [x] I've added a changeset if this PR contains user-facing or noteworthy changes - [x] I've commented my code, particularly in hard-to-understand areas - [x] I've made corresponding changes to the documentation - [x] I've tested my code for breaking changes and added the corresponding footer in this PR if needed
1 parent cc32952 commit c5cc132

File tree

10 files changed

+80
-48
lines changed

10 files changed

+80
-48
lines changed

apps/cbt-hydrogen/app/root.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import type {Shop} from '@shopify/hydrogen/storefront-api-types';
1010
import {type LinksFunction, type LoaderArgs} from '@shopify/remix-oxygen';
1111
import favicon from '../public/favicon.svg';
12-
import styles from './styles/app.css';
12+
import styles from './styles/tailwind.css';
1313

1414
export const links: LinksFunction = () => {
1515
return [
+34-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
import {
2+
Accordion,
3+
AccordionContent,
4+
AccordionItem,
5+
AccordionTrigger,
6+
} from '@code-internet-applications/react';
7+
18
export default function Homepage() {
2-
return <h1>Hello CODE.</h1>;
9+
return (
10+
<>
11+
<p className="mb-8">Hello CODE.</p>
12+
13+
<Accordion type="single" collapsible className="w-full">
14+
<AccordionItem value="item-1">
15+
<AccordionTrigger>Is it accessible?</AccordionTrigger>
16+
<AccordionContent>
17+
Yes. It adheres to the WAI-ARIA design pattern.
18+
</AccordionContent>
19+
</AccordionItem>
20+
<AccordionItem value="item-2">
21+
<AccordionTrigger>Is it styled?</AccordionTrigger>
22+
<AccordionContent>
23+
Yes. It comes with default styles that matches the other components
24+
aesthetic.
25+
</AccordionContent>
26+
</AccordionItem>
27+
<AccordionItem value="item-3">
28+
<AccordionTrigger>Is it animated?</AccordionTrigger>
29+
<AccordionContent>
30+
Yes. Its animated by default, but you can disable it if you prefer.
31+
</AccordionContent>
32+
</AccordionItem>
33+
</Accordion>
34+
</>
35+
);
336
}

apps/cbt-hydrogen/app/styles/app.css

-31
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;

apps/cbt-hydrogen/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"prettier": "@shopify/prettier-config",
1515
"dependencies": {
16+
"@code-internet-applications/react": "workspace:*",
1617
"@remix-run/react": "1.15.0",
1718
"@shopify/cli": "3.45.0",
1819
"@shopify/cli-hydrogen": "^4.2.1",
@@ -23,6 +24,7 @@
2324
"isbot": "^3.6.10"
2425
},
2526
"devDependencies": {
27+
"@code-internet-applications/tsconfig": "workspace:*",
2628
"@remix-run/dev": "1.15.0",
2729
"@shopify/oxygen-workers-types": "^3.17.2",
2830
"@shopify/prettier-config": "^1.1.2",

apps/cbt-hydrogen/remix.config.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
module.exports = {
33
appDirectory: 'app',
44
ignoredRouteFiles: ['**/.*'],
5-
watchPaths: ['./public'],
5+
watchPaths: [
6+
'./public',
7+
'../../packages/**/**/*.{js,ts,jsx,tsx,mdx}',
8+
'../../packages/**/**/**/*.{js,ts,jsx,tsx,mdx}',
9+
],
610
server:
711
process.env.NODE_ENV === 'development' ? './server-dev.ts' : './server.ts',
812
/**
@@ -18,6 +22,7 @@ module.exports = {
1822
serverPlatform: 'neutral',
1923
serverMinify: process.env.NODE_ENV === 'production',
2024
future: {
25+
unstable_tailwind: true,
2126
v2_meta: true,
2227
v2_errorBoundary: true,
2328
v2_routeConvention: true,

apps/cbt-hydrogen/server.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ export default async function (request: Request): Promise<Response> {
2323
PUBLIC_STORE_DOMAIN: '',
2424
PUBLIC_STOREFRONT_ID: '',
2525
};
26-
env.SESSION_SECRET = process.env.SESSION_SECRET;
27-
env.PUBLIC_STOREFRONT_API_TOKEN = process.env.PUBLIC_STOREFRONT_API_TOKEN;
28-
env.PRIVATE_STOREFRONT_API_TOKEN = process.env.PRIVATE_STOREFRONT_API_TOKEN;
29-
env.PUBLIC_STOREFRONT_API_VERSION =
30-
process.env.PUBLIC_STOREFRONT_API_VERSION;
31-
env.PUBLIC_STORE_DOMAIN = process.env.PUBLIC_STORE_DOMAIN;
26+
env.SESSION_SECRET = process.env.SESSION_SECRET as string;
27+
env.PUBLIC_STOREFRONT_API_TOKEN = process.env
28+
.PUBLIC_STOREFRONT_API_TOKEN as string;
29+
env.PRIVATE_STOREFRONT_API_TOKEN = process.env
30+
.PRIVATE_STOREFRONT_API_TOKEN as string;
31+
env.PUBLIC_STOREFRONT_API_VERSION = process.env
32+
.PUBLIC_STOREFRONT_API_VERSION as string;
33+
env.PUBLIC_STORE_DOMAIN = process.env.PUBLIC_STORE_DOMAIN as string;
3234

3335
/**
3436
* Open a cache instance in the worker and a custom session instance.
@@ -38,7 +40,7 @@ export default async function (request: Request): Promise<Response> {
3840
}
3941

4042
const [session] = await Promise.all([
41-
HydrogenSession.init(request, [process.env.SESSION_SECRET]),
43+
HydrogenSession.init(request, [process.env.SESSION_SECRET as string]),
4244
]);
4345

4446
/**

apps/cbt-hydrogen/tailwind.config.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type {Config} from 'tailwindcss';
2+
import {tailwindConfig} from '../../packages/config/tailwind-config/tailwind.config';
3+
4+
export default {
5+
presets: [tailwindConfig],
6+
content: [
7+
'../../packages/**/**/*.{js,ts,jsx,tsx,mdx}',
8+
'../../packages/**/**/**/*.{js,ts,jsx,tsx,mdx}',
9+
'./app/**/*.{js,jsx,ts,tsx}',
10+
],
11+
} satisfies Config;

apps/cbt-hydrogen/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"extends": "@code-internet-applications/tsconfig",
23
"include": ["./**/*.d.ts", "./**/*.ts", "./**/*.tsx"],
34
"compilerOptions": {
45
"lib": ["DOM", "DOM.Iterable", "ES2022"],
@@ -13,7 +14,7 @@
1314
"forceConsistentCasingInFileNames": true,
1415
"skipLibCheck": true,
1516
"baseUrl": ".",
16-
"types": ["@shopify/oxygen-workers-types"],
17+
"types": ["@shopify/oxygen-workers-types", "node"],
1718
"paths": {
1819
"~/*": ["app/*"]
1920
},

pnpm-lock.yaml

+12-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)