-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into taylor/tailwind
- Loading branch information
Showing
17 changed files
with
6,666 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ dist | |
node_modules | ||
.eslintrc.js | ||
./*.js | ||
storybook-static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
extends: "../../.eslintrc.cjs", | ||
extends: ["../../.eslintrc.cjs", "plugin:storybook/recommended"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { join, dirname, resolve } from "path"; | ||
|
||
/** | ||
* This function is used to resolve the absolute path of a package. | ||
* It is needed in projects that use Yarn PnP or are set up within a monorepo. | ||
*/ | ||
function getAbsolutePath(value) { | ||
return dirname(require.resolve(join(value, "package.json"))); | ||
} | ||
|
||
/** @type { import('@storybook/react-webpack5').StorybookConfig } */ | ||
const config = { | ||
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"], | ||
addons: [ | ||
getAbsolutePath("@storybook/addon-links"), | ||
getAbsolutePath("@storybook/addon-essentials"), | ||
getAbsolutePath("@storybook/addon-onboarding"), | ||
getAbsolutePath("@storybook/addon-interactions"), | ||
getAbsolutePath("@storybook/addon-styling-webpack"), | ||
], | ||
framework: { | ||
name: getAbsolutePath("@storybook/react-webpack5"), | ||
options: { | ||
builder: { | ||
useSWC: true, | ||
}, | ||
}, | ||
}, | ||
webpackFinal: async config => { | ||
config.module.rules.push({ | ||
test: /\.css$/, | ||
use: [ | ||
{ | ||
loader: "postcss-loader", | ||
options: { | ||
postcssOptions: { | ||
plugins: { tailwindcss: {}, autoprefixer: {} }, | ||
}, | ||
}, | ||
}, | ||
], | ||
include: resolve(__dirname, "../"), | ||
}); | ||
return config; | ||
}, | ||
docs: { | ||
autodocs: "tag", | ||
}, | ||
}; | ||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import "../src/main.css"; | ||
|
||
/** @type { import('@storybook/react').Preview } */ | ||
const preview = { | ||
parameters: { | ||
actions: { argTypesRegex: "^on[A-Z].*" }, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default preview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.charCount { | ||
@apply text-acc-grey; | ||
} | ||
|
||
.charCountOver { | ||
@apply text-acc-red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import cx from "classnames"; | ||
import React from "react"; | ||
import css from "./index.module.css"; | ||
|
||
export const maxChar = 2048; | ||
|
||
type Props = { | ||
desc: string; | ||
className?: string; | ||
}; | ||
|
||
export default function CharCount(props: Props) { | ||
return ( | ||
<span | ||
className={cx(css.charCount, props.className, { | ||
[css.charCountOver]: props.desc.length > maxChar, | ||
})} | ||
> | ||
{props.desc.length}/{maxChar} | ||
</span> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { nTimes } from "@dolthub/web-utils"; | ||
import { render, screen } from "@testing-library/react"; | ||
import React from "react"; | ||
import CharCount from "../CharCount"; | ||
import css from "./index.module.css"; | ||
|
||
const tilde = () => "~"; | ||
|
||
const mocks = [ | ||
{ words: "", over: false }, | ||
{ words: nTimes(9, tilde).join(""), over: false }, | ||
{ words: nTimes(2050, tilde).join(""), over: true }, | ||
]; | ||
|
||
describe("test CharCount", () => { | ||
mocks.forEach(mock => { | ||
it(`renders CharCount for word length of ${mock.words.length}`, () => { | ||
render(<CharCount desc={mock.words} className="classname" />); | ||
|
||
const content = screen.getByText(`${mock.words.length}/2048`); | ||
expect(content).toBeVisible(); | ||
expect(content).toHaveClass(css.charCount); | ||
expect(content).toHaveClass("classname"); | ||
|
||
if (mock.over) { | ||
expect(content).toHaveClass(css.charCountOver); | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* Fonts import should come first */ | ||
@import url("https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i,700,700i|Space+Mono:400,400i,700,700i&display=swap"); | ||
|
||
@tailwind base; | ||
|
||
html, | ||
body { | ||
@apply font-sans text-primary; | ||
} | ||
|
||
h1, | ||
h2, | ||
h3, | ||
h4 { | ||
@apply text-primary; | ||
} | ||
|
||
h2, | ||
h3, | ||
h4 { | ||
@apply font-semibold; | ||
} | ||
|
||
h1 { | ||
@apply font-bold text-3xl; | ||
} | ||
|
||
h2 { | ||
@apply text-2xl; | ||
} | ||
|
||
h3 { | ||
@apply text-xl; | ||
} | ||
|
||
h4 { | ||
@apply text-lg; | ||
} | ||
|
||
/* a { | ||
@apply font-semibold text-link-1; | ||
} | ||
a:hover { | ||
@apply text-link-2; | ||
} */ | ||
|
||
p { | ||
@apply text-sm text-primary leading-normal; | ||
} | ||
|
||
@tailwind components; | ||
@tailwind utilities; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import CharCount from "../CharCount"; | ||
|
||
const meta: Meta<typeof CharCount> = { | ||
title: "CharCount", | ||
component: CharCount, | ||
tags: ["autodocs"], | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof CharCount>; | ||
|
||
export const WithinLimit: Story = { | ||
args: { | ||
desc: "short desc", | ||
}, | ||
}; | ||
|
||
export const TooLong: Story = { | ||
args: { | ||
desc: "abc".repeat(2048), | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import React from "react"; | ||
import ExternalLink from "../ExternalLink"; | ||
|
||
const meta: Meta<typeof ExternalLink> = { | ||
title: "ExternalLink", | ||
component: ExternalLink, | ||
tags: ["autodocs"], | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof ExternalLink>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
href: "https://dolthub.com", | ||
children: <span>Go to DoltHub in new tab</span>, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import React from "react"; | ||
import Loader from "../Loader"; | ||
|
||
const meta: Meta<typeof Loader> = { | ||
title: "Loader", | ||
component: Loader, | ||
tags: ["autodocs"], | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Loader>; | ||
|
||
export const NotLoadedNoChild: Story = { | ||
args: { | ||
loaded: false, | ||
}, | ||
}; | ||
|
||
export const NotLoadedWithChild: Story = { | ||
args: { | ||
loaded: false, | ||
children: <span>Loaded</span>, | ||
}, | ||
}; | ||
|
||
export const LoadedWithChild: Story = { | ||
args: { | ||
loaded: true, | ||
children: <span>Loaded</span>, | ||
}, | ||
}; | ||
|
||
export const LoadedNoChild: Story = { | ||
args: { | ||
loaded: true, | ||
}, | ||
}; | ||
|
||
export const NotLoadedWithStyles: Story = { | ||
args: { | ||
loaded: false, | ||
options: { | ||
color: "red", | ||
lines: 4, | ||
radius: 10, | ||
shadow: true, | ||
speed: 0.5, | ||
opacity: 0.2, | ||
}, | ||
}, | ||
}; |
Oops, something went wrong.