Skip to content

Commit 005d78a

Browse files
tulup-connerRicardo Lüders
andauthored
feat(theme): add theme={} attribute to components that need it (#611)
* feat(theme): adding theme prop to components * feat(/theme/default): finish migrating components to use a `root` theme Follow up to #500 BREAKING CHANGE: Like in #500, this version permanently changes the `FlowbiteTheme` for numerous components. The philosophy is that themes will more clearly reflect the component's structure. For example, an `<Accordion>` can contain any number of `<Accordion.Title>` or `<Accordion.Content>` sections. The theme used to look like: ```js accordion: { base: "..", content: "..", flush: "..", title: "..", } ``` And now, the theme for an `<Accordion>` looks like: ``` js accordion: { root: { base: "..", flush: "..", }, content: "..", title: "..", } ``` So now the options in the theme which apply to the `<Accordion>` itself will always be found under `root`. Likewise, `<Accordion.Content>` can be themed via the `content` subsection. This ultimately will apply to all components. * ci(eslint): remove `prettier` plugins for `eslint` Instead, use `prettier-plugin-tailwindcss`, which is sufficient. * refactor(/lib/*): use `yarn prettier` with `prettier-plugin-tailwindcss` * fix(/lib/components/*.spec): resolve test errors caused by migrating theme * feat(/lib/components/*): add `theme={}` attribute to components that need it See notes in #566 * fix(/lib/components/accordion): fix `<Accordion theme={}` types wrong interface * docs(/pages/theme): update `/theme` documentation to include new theme strategies We have more powerful options to customize themes now, and they deserve proper documentation. * ci(eslint): fix `eslint` configured to ignore `src/lib/` Well this sucks! We've not been linting the vast majority of the actual code of the library due to a misconfigured `.eslintignore`. Mass-fix coming. * ci(eslint): resolve outstanding `eslint` issues * fix(/lib/components/footer/footertitle): allow `<Footer.Title as="..">` to not use `<h2>` You can cast the component to a component of your own, or a generic HTML element, e.g., `<Footer.Title as="h3">`. resolve #594 * fix(/lib/components/modal): fix `Modal` expects `document` to exist So, I originally fixed this issue across every component in #124, but the bug was reintroduced by resolve #609 * ci(.github/workflows/build): upgrade `codecov-action` -> `v3` --------- Co-authored-by: Ricardo Lüders <[email protected]>
1 parent 6501245 commit 005d78a

File tree

126 files changed

+2225
-1487
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+2225
-1487
lines changed

.eslintignore

Lines changed: 0 additions & 6 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/build.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ jobs:
4545
run: yarn build
4646

4747
- name: 📊 Upload coverage to Codecov
48-
uses: codecov/codecov-action@v2
48+
uses: codecov/codecov-action@v3
4949
with:
5050
fail_ci_if_error: false
5151
files: coverage/coverage-final.json
52-
token: ${{ secrets.CODECOV_TOKEN }}
5352
verbose: false
5453

5554
- name: 📖 Build Storybook

package.json

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,17 @@
103103
"cypress-axe": "^1.0.0",
104104
"cz-conventional-changelog": "3.3.0",
105105
"eslint": "^8.21.0",
106-
"eslint-config-prettier": "^8.5.0",
107-
"eslint-plugin-prettier": "^4.2.1",
108106
"eslint-plugin-react": "^7.30.1",
109107
"eslint-plugin-react-hooks": "^4.6.0",
110108
"eslint-plugin-storybook": "^0.6.4",
111-
"eslint-plugin-tailwindcss": "^3.6.0",
112109
"flowbite": "^1.5.4",
113110
"husky": "^8.0.1",
114111
"jsdom": "^20.0.1",
115112
"lint-staged": "^13.0.3",
116113
"postcss": "^8.4.18",
117114
"prettier": "^2.7.1",
118115
"prettier-plugin-organize-imports": "^3.0.3",
116+
"prettier-plugin-tailwindcss": "^0.2.2",
119117
"react": "^18.2.0",
120118
"react-app-rewired": "^2.2.1",
121119
"react-dom": "^18.2.0",
@@ -165,5 +163,42 @@
165163
"react": "^18.2.0",
166164
"react-dom": "^18.2.0"
167165
}
166+
},
167+
"eslintConfig": {
168+
"extends": [
169+
"eslint:recommended",
170+
"plugin:@typescript-eslint/recommended",
171+
"plugin:react-hooks/recommended",
172+
"plugin:storybook/recommended"
173+
],
174+
"ignorePatterns": [
175+
"/build",
176+
"/docs",
177+
"/lib",
178+
"commitlint.config.js",
179+
"config-overrides.js",
180+
"lint-staged.js",
181+
"postcss.config.js",
182+
"tailwind.config.js"
183+
],
184+
"parser": "@typescript-eslint/parser",
185+
"parserOptions": {
186+
"ecmaFeatures": {
187+
"jsx": true
188+
},
189+
"project": [
190+
"tsconfig.json",
191+
"cypress/tsconfig.json"
192+
]
193+
},
194+
"plugins": [
195+
"@typescript-eslint",
196+
"react-hooks",
197+
"storybook"
198+
],
199+
"root": true,
200+
"rules": {
201+
"@typescript-eslint/consistent-type-imports": "warn"
202+
}
168203
}
169204
}

src/docs/pages/AlertsPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const AlertsPage: FC = () => {
3636
{
3737
title: 'Rounded',
3838
code: (
39-
<Alert color="warning" rounded={false}>
39+
<Alert color="warning" rounded>
4040
{alertText}
4141
</Alert>
4242
),

src/docs/pages/DropdownPage.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const DropdownPage: FC = () => {
3535
<Dropdown label="Dropdown button">
3636
<Dropdown.Header>
3737
<span className="block text-sm">Bonnie Green</span>
38-
<span className="block text-sm font-medium truncate">[email protected]</span>
38+
<span className="block truncate text-sm font-medium">[email protected]</span>
3939
</Dropdown.Header>
4040
<Dropdown.Item>Dashboard</Dropdown.Item>
4141
<Dropdown.Item>Settings</Dropdown.Item>
@@ -62,7 +62,7 @@ const DropdownPage: FC = () => {
6262
<Dropdown label="Dropdown">
6363
<Dropdown.Header>
6464
<span className="block text-sm">Bonnie Green</span>
65-
<span className="block text-sm font-medium truncate">[email protected]</span>
65+
<span className="block truncate text-sm font-medium">[email protected]</span>
6666
</Dropdown.Header>
6767
<Dropdown.Item icon={HiViewGrid}>Dashboard</Dropdown.Item>
6868
<Dropdown.Item icon={HiCog}>Settings</Dropdown.Item>
@@ -86,7 +86,7 @@ const DropdownPage: FC = () => {
8686
{
8787
title: 'Sizing',
8888
code: (
89-
<div className="flex gap-4 items-center">
89+
<div className="flex items-center gap-4">
9090
<Dropdown label="Small dropdown" size="sm">
9191
<Dropdown.Item>Dashboard</Dropdown.Item>
9292
<Dropdown.Item>Settings</Dropdown.Item>
@@ -106,7 +106,7 @@ const DropdownPage: FC = () => {
106106
title: 'Placement',
107107
code: (
108108
<div className="flex flex-col gap-4">
109-
<div className="flex gap-4 items-center">
109+
<div className="flex items-center gap-4">
110110
<Dropdown label="Dropdown top" placement="top">
111111
<Dropdown.Item>Dashboard</Dropdown.Item>
112112
<Dropdown.Item>Settings</Dropdown.Item>
@@ -132,7 +132,7 @@ const DropdownPage: FC = () => {
132132
<Dropdown.Item>Sign out</Dropdown.Item>
133133
</Dropdown>
134134
</div>
135-
<div className="flex gap-4 items-center">
135+
<div className="flex items-center gap-4">
136136
<Dropdown label="Dropdown left start" placement="left-start">
137137
<Dropdown.Item>Dashboard</Dropdown.Item>
138138
<Dropdown.Item>Settings</Dropdown.Item>

src/docs/pages/PaginationPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { FC } from 'react';
22
import { useState } from 'react';
3-
import { Pagination } from '../../lib/components/Pagination';
3+
import { Pagination } from '../../lib';
44
import type { CodeExample } from './DemoPage';
55
import { DemoPage } from './DemoPage';
66

7-
const PaginationPage: FC = (): JSX.Element => {
7+
const PaginationPage: FC = () => {
88
const [currentPage, setCurrentPage] = useState(1);
99

1010
const onPageChange = (page: number) => {

src/docs/pages/TabsPage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { FC, useRef, useState } from 'react';
1+
import type { FC } from 'react';
2+
import { useRef, useState } from 'react';
23
import { HiAdjustments, HiClipboardList, HiUserCircle } from 'react-icons/hi';
34
import { MdDashboard } from 'react-icons/md';
4-
import { Button, Tabs, TabsRef } from '../../lib';
5+
import type { TabsRef } from '../../lib';
6+
import { Button, Tabs } from '../../lib';
57
import type { CodeExample } from './DemoPage';
68
import { DemoPage } from './DemoPage';
79

0 commit comments

Comments
 (0)