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

feat(sample): Tailwind and Shadcn/ui flavor #5

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ Note that this template is meant to be customized. Here are some things you migh
- [ ] The favicons in the [`public/icons`](./public/icons/) folder. You can use [this generator](https://realfavicongenerator.net/) to generate them from an image.
- [ ] The github username and email in the [`integration.yaml`](./.github/workflows/integration.yaml) file.
- [ ] The environment variables in the [`Dockerfile`](./Dockerfile) to match your production environment. Note that this is needed because, as React is a client-side framework, the environment variables are embedded in the build.
- [ ] The [`shadcn/ui`](https://ui.shadcn.com/) theme. As shadcn/ui is a customizable library, you can use a [pre-defined](https://ui.shadcn.com/themes) theme or create your own by modifying the [`src/index.css`](./src/index.css) file.
16 changes: 16 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "src/index.css",
"baseColor": "slate",
"cssVariables": true
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
Empty file removed e2e/.gitkeep
Empty file.
38 changes: 38 additions & 0 deletions e2e/characters-infinite-scroll.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { expect, test } from "@playwright/test";

test("infinite scroll", async ({ page }) => {
await page.goto("/");

const CARDS_SELECTOR = "li.character-card";
const SKELETONS_SELECTOR = "div.character-card-skeleton";
const CARDS_PER_PAGE = 20;
const SKELETONS_PER_LOAD = 12;

// Should show 20 skeleton cards before loading
await page.waitForSelector(SKELETONS_SELECTOR);
const skeletonCards = await page.$$(SKELETONS_SELECTOR);
expect(skeletonCards.length).toBe(SKELETONS_PER_LOAD);

// Should have 20 characters at the beginning after loading
await page.waitForSelector(CARDS_SELECTOR);
const initialCharacters = await page.$$(CARDS_SELECTOR);
expect(initialCharacters.length).toBe(CARDS_PER_PAGE);

// Scroll to bottom
await page.evaluate(() => {
window.scrollTo(0, document.body.scrollHeight);
});

// Should show the same amount of skeleton cards after scrolling
await page.waitForSelector(SKELETONS_SELECTOR);
const skeletonCardsAfterScroll = await page.$$(SKELETONS_SELECTOR);
expect(skeletonCardsAfterScroll.length).toBe(SKELETONS_PER_LOAD);

// Wait until the skeletons disappear
await expect(page.locator(SKELETONS_SELECTOR)).toHaveCount(0);

// Should have 40 characters after loading
await page.waitForSelector(CARDS_SELECTOR);
const charactersAfterScroll = await page.$$(CARDS_SELECTOR);
expect(charactersAfterScroll.length).toBe(CARDS_PER_PAGE * 2);
});
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<title>{{ Title }}</title>
</head>
<body>
<div id="root"></div>
<div id="root" class="bg-primary-foreground"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,19 @@
"format:fix": "prettier src/ --write"
},
"dependencies": {
"@radix-ui/react-slot": "^1.0.2",
"@tanstack/react-query": "5.0.0",
"@tanstack/react-query-devtools": "^5.0.1",
"@uidotdev/usehooks": "2.4.1",
"axios": "1.5.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"lucide-react": "^0.288.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "6.17.0"
"react-router-dom": "6.17.0",
"tailwind-merge": "^1.14.0",
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@playwright/test": "^1.39.0",
Expand All @@ -38,11 +45,14 @@
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"@vitejs/plugin-react-swc": "^3.4.0",
"autoprefixer": "10.4.16",
"eslint": "^8.51.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"postcss": "8.4.31",
"prettier": "3.0.3",
"tailwindcss": "3.3.3",
"typescript": "^5.2.2",
"vite": "^4.5.0"
}
Expand Down
Loading