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: added html components #847

Open
wants to merge 36 commits into
base: v3-test
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
07db1fc
Merge pull request #841 from creativetimofficial/v3-test
marqbeniamin Nov 18, 2024
187c744
wip: test code render
marqbeniamin Nov 19, 2024
6674897
Update test.mdx
marqbeniamin Nov 19, 2024
727e8e0
Update CodeSnippet.tsx
marqbeniamin Nov 19, 2024
d3401e9
Update ComponentPreview.tsx
marqbeniamin Nov 19, 2024
9539266
Update route.ts
marqbeniamin Nov 19, 2024
1f99298
Update CodeSnippet.tsx
marqbeniamin Nov 19, 2024
b3ad34d
Update next.config.js
marqbeniamin Nov 19, 2024
6258771
Update test.mdx
marqbeniamin Nov 19, 2024
83b5fa7
wip: change paths
marqbeniamin Nov 19, 2024
4542e4a
Update next.config.js
marqbeniamin Nov 19, 2024
a853778
wip: code preview
marqbeniamin Nov 19, 2024
af5b11f
Merge pull request #842 from creativetimofficial/v3-test
dragosct Nov 19, 2024
b71886c
Merge pull request #843 from creativetimofficial/v3-test
marqbeniamin Nov 19, 2024
7bb47f2
Merge branch 'v3-test' into feat/html-components
marqbeniamin Nov 20, 2024
1b4e934
Update package.json
marqbeniamin Nov 20, 2024
f60a810
Update page.tsx
marqbeniamin Nov 20, 2024
e5d31d8
Delete CodeSection.tsx
marqbeniamin Nov 20, 2024
6c2a1be
Create PreviewWithCode.tsx
marqbeniamin Nov 20, 2024
4878346
Update accordion-demo.tsx
marqbeniamin Nov 20, 2024
fdabdd4
Update CodeSnippet.tsx
marqbeniamin Nov 20, 2024
2fbcc12
Update test.mdx
marqbeniamin Nov 20, 2024
47f45bb
Merge pull request #845 from creativetimofficial/v3-test
dragosct Nov 20, 2024
3c548a2
Merge branch 'v3' into feat/html-components
marqbeniamin Nov 20, 2024
d41aa91
wip: add alert html componenets
marqbeniamin Nov 20, 2024
83e809f
Update PreviewWithCode.tsx
marqbeniamin Nov 21, 2024
e0ee16b
Update CodeSnippet.tsx
marqbeniamin Nov 21, 2024
c486ac9
Update CodeSnippet.tsx
marqbeniamin Nov 21, 2024
b51676a
Delete route.ts
marqbeniamin Nov 21, 2024
6fa3517
Delete test.mdx
marqbeniamin Nov 21, 2024
a8d54e5
Update tsconfig.json
marqbeniamin Nov 21, 2024
a260a87
solve old version
marqbeniamin Nov 21, 2024
475513d
WIP: added badges
marqbeniamin Nov 22, 2024
dcea378
local change
axelut Dec 3, 2024
07377fa
Revert "local change"
axelut Dec 3, 2024
329adee
Merge branch 'v3' into feat/html-components
marqbeniamin Dec 4, 2024
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
25 changes: 24 additions & 1 deletion apps/site/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const nextConfig = {
ignoreBuildErrors: true,
},
transpilePackages: ["next-mdx-remote"],
assetPrefix: process.env.NEXT_PUBLIC_SITE_URL,
assetPrefix: process.env.NEXT_PUBLIC_SITE_URL,
async redirects() {
return [
{
Expand Down Expand Up @@ -86,6 +86,29 @@ const nextConfig = {
},
];
},
webpack: {
configure: (webpackConfig) => {
// webpackConfig.module.rules.push({
// test: /\.(ts|tsx|html|mdx|md|js|jsx)$/,
// loader: 'raw-loader',
// options: { transpileOnly: true },
// });

webpackConfig.module.rules.push({
test: /\.html$/,
use: 'raw-loader',
});

// For .tsx files imported with ?raw
webpackConfig.module.rules.push({
test: /\.tsx$/,
resourceQuery: /raw/, // applies only when '?raw' is present
use: 'raw-loader',
});

return webpackConfig;
},
},
};

module.exports = nextConfig;
3 changes: 3 additions & 0 deletions apps/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@
"next-mdx-remote": "5.0.0",
"next-nprogress-bar": "2.3.13",
"next-themes": "0.2.1",
"prettier": "3.3.3",
"raw-loader": "4.0.2",
"react": "18.2.0",
"react-apexcharts": "1.4.1",
"react-day-picker": "8.10.0",
"react-dom": "18.2.0",
"react-hook-form": "7.51.2",
"react-syntax-highlighter": "15.6.1",
"rehype-autolink-headings": "7.0.0",
"rehype-pretty-code": "0.3.2",
"rehype-slug": "6.0.0",
Expand Down
15 changes: 12 additions & 3 deletions apps/site/src/app/docs/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
CodePreview,
ColorPalette,
FrameworkCard,
ComponentPreview,
OldComponentPreview,
} from "@components";
import Link from "next/link";
import { Code } from "bright";
Expand Down Expand Up @@ -103,9 +103,15 @@ import * as HTMLVideo from "@components/docs-html/video";
import * as HTMLCheckbox from "@components/docs-html/checkbox";
import * as HTMLRadio from "@components/docs-html/radio";
import * as HTMLSwitch from "@components/docs-html/switch";
import * as HTMLBadge from "@components/docs-html/badge";
// import * as HTMLBadge from "@components/docs-html/badge";
import * as HTMLAccordion from "@components/docs-html/accordion";



import CodeSnippet from '@components/CodeSnippet';
import ComponentPreview from '@components/ComponentPreview';
import PreviewWithCode from '@components/PreviewWithCode';

async function readDocsContentFn(pathUrl: string) {
const fullPath = `${path.join(
process.cwd(),
Expand Down Expand Up @@ -202,7 +208,10 @@ export default async function Docs({ params: { slug } }) {
CodePreview,
ColorPalette,
FrameworkCard,
OldComponentPreview,
ComponentPreview,
PreviewWithCode,
CodeSnippet,

// default-components
pre: Code,
Expand Down Expand Up @@ -361,7 +370,7 @@ export default async function Docs({ params: { slug } }) {
HTMLCheckbox,
HTMLRadio,
HTMLSwitch,
HTMLBadge,
// HTMLBadge,
HTMLAccordion,
}}
/>
Expand Down
175 changes: 11 additions & 164 deletions apps/site/src/app/docs/content/html/accordion.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,180 +21,27 @@ We created a series of accordion examples to help you build easier your applicat

Here's how to implement a simple and responsive `Accordion` component. It can be used for FAQs in your website.

<ComponentPreview demo={<HTMLAccordion.AccordionDemo />}>
```html
<div class="w-full">
<div
data-open="true"
class="items-center justify-between block w-full border-b cursor-pointer group border-surface"
>
<button
data-open="true"
class="flex items-center justify-between w-full py-3 font-medium text-left text-black dark:text-white"
>
Material Tailwind React
<svg
width="1.5em"
height="1.5em"
stroke-width="1.5"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
color="currentColor"
class="h-4 w-4 group-data-[open=true]:rotate-180"
>
<path
d="M6 9L12 15L18 9"
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
></path>
</svg>
</button>
<div
class="block h-auto pb-3 text-foreground"
data-content
data-open="true"
>
Material Tailwind is an open-source crafted in Tailwind CSS. Get
Material Tailwind and take advantage of its free components and
features that will help you set up your web project quickly.
</div>
</div>
<div
data-open="false"
class="items-center justify-between block w-full border-b cursor-pointer group border-surface"
>
<button
data-open="false"
class="flex items-center justify-between w-full py-3 font-medium text-left text-black dark:text-white"
>
Material Tailwind HTML
<svg
width="1.5em"
height="1.5em"
stroke-width="1.5"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
color="currentColor"
class="h-4 w-4 group-data-[open=true]:rotate-180"
>
<path
d="M6 9L12 15L18 9"
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
></path>
</svg>
</button>
<div
class="hidden h-0 pb-3 text-foreground"
data-content
data-open="false"
>
Material Tailwind is an open-source crafted in Tailwind CSS. Get
Material Tailwind and take advantage of its free components and
features that will help you set up your web project quickly.
</div>
</div>

<div
data-open="false"
class="items-center justify-between block w-full border-b cursor-pointer group border-surface"
>
<button
data-open="false"
class="flex items-center justify-between w-full py-3 font-medium text-left text-black dark:text-white"
>
Material Tailwind Vue
<svg
width="1.5em"
height="1.5em"
stroke-width="1.5"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
color="currentColor"
class="h-4 w-4 group-data-[open=true]:rotate-180"
>
<path
d="M6 9L12 15L18 9"
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
></path>
</svg>
</button>
<div
class="hidden h-0 pb-3 text-foreground"
data-content
data-open="false"
>
Material Tailwind is an open-source crafted in Tailwind CSS. Get
Material Tailwind and take advantage of its free components and
features that will help you set up your web project quickly.
</div>
</div>
</div>

<!-- script for the accordion items functionality -->
<script>
const accordionItems = document.querySelectorAll("[data-open]");

const setAccordionState = (item, isOpen) => {
const content = item.querySelector("div[data-content]");
const button = item.querySelector("button");

item.setAttribute("data-open", isOpen ? "true" : "false");
content?.setAttribute("data-open", isOpen ? "true" : "false");
button?.setAttribute("data-open", isOpen ? "true" : "false");

if (content) {
content.classList.toggle("hidden", !isOpen);
content.classList.toggle("h-0", !isOpen);
content.classList.toggle("block", isOpen);
content.classList.toggle("h-auto", isOpen);
}
};

const toggleAccordion = (clickedItem) => {
const isCurrentlyOpen = clickedItem.getAttribute("data-open") === "true";
accordionItems.forEach((item) =>
setAccordionState(item, item === clickedItem && !isCurrentlyOpen),
);
};

<!-- Add event listeners for each accordion item -->
accordionItems.forEach((item) => {
const button = item.querySelector("button");
if (button) {
button.addEventListener("click", () => toggleAccordion(item));
}
});
</script>
```
</ComponentPreview>
<PreviewWithCode relativePath="accordion/accordion-demo.tsx" language="html" />

---

## Accordion All Open

You can set all the `Accordion` items to be open by default by passing an array of values to the `defaultValue` prop.

<ComponentPreview demo={<HTMLAccordion.AccordionAllOpen />}>
<OldComponentPreview demo={<HTMLAccordion.AccordionAllOpen />}>
```html
<div></div>
```
</ComponentPreview>
</OldComponentPreview>

---

## Controlled Accordion

The `Accordion` component could be either controlled or uncontrolled. In the controlled mode, you can manage the state of the `Accordion` component by yourself. You can use the `value` and `onValueChange` props to control the state of the `Accordion` component.

<ComponentPreview demo={<Accordion.ControlledAccordion />}>
<OldComponentPreview demo={<Accordion.ControlledAccordion />}>
```tsx
import * as React from "react";
import { Accordion, Button } from "@material-tailwind/react";
Expand Down Expand Up @@ -267,7 +114,7 @@ export function ControlledAccordion() {
);
}
```
</ComponentPreview>
</OldComponentPreview>

---

Expand All @@ -276,7 +123,7 @@ export function ControlledAccordion() {
You can customize the `Accordion` trigger icon by using the `Accordion.Trigger` component. To make it work, you need to use `group-data-[open=true]` for the icons to show/hide based on the `Accordion` state.


<ComponentPreview demo={<Accordion.AccordionCustomIcon />}>
<OldComponentPreview demo={<Accordion.AccordionCustomIcon />}>
```tsx
import { Accordion } from "@material-tailwind/react";
import { Minus, Plus } from "iconoir-react";
Expand Down Expand Up @@ -324,15 +171,15 @@ export function AccordionCustomIcon() {
);
}
```
</ComponentPreview>
</OldComponentPreview>

---

## Accordion Custom Styles

You can customize the `Accordion` component by using the `className` prop. In the example below, we've showcased how to create a custom style for the `Accordion` component.

<ComponentPreview demo={<Accordion.AccordionCustomStyles />}>
<OldComponentPreview demo={<Accordion.AccordionCustomStyles />}>
```tsx
import { Accordion } from "@material-tailwind/react";
import { NavArrowDown } from "iconoir-react";
Expand Down Expand Up @@ -386,15 +233,15 @@ export function AccordionCustomStyles() {
);
}
```
</ComponentPreview>
</OldComponentPreview>

---

## Accordion Disabled

You can disable the `Accordion` item by adding the `disabled` prop. This will prevent the user from interacting with the `Accordion` item.

<ComponentPreview demo={<Accordion.AccordionDisabled />}>
<OldComponentPreview demo={<Accordion.AccordionDisabled />}>
```tsx
import { Accordion } from "@material-tailwind/react";
import { NavArrowDown } from "iconoir-react";
Expand Down Expand Up @@ -439,4 +286,4 @@ export function AccordionDisabled() {
);
}
```
</ComponentPreview>
</OldComponentPreview>
Loading