Skip to content

Commit a145455

Browse files
Vojtěch Václav Portešvojtechportes
authored andcommitted
feat: Added Fluent UI adapter
- Added Fluent UI v8 adapter - Restructured and updated library website - Updated readme
1 parent 56d6a32 commit a145455

19 files changed

Lines changed: 1757 additions & 193 deletions

File tree

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ subpath exports:
5353
- `@vojtechportes/react-query-builder/mui/v7` for applications still on MUI 7
5454
- `@vojtechportes/react-query-builder/antd/v6` for new Ant Design projects
5555
- `@vojtechportes/react-query-builder/antd/v5` for applications still on Ant Design 5
56+
- `@vojtechportes/react-query-builder/fluentui/v8` for Fluent UI React 8 projects
5657

5758
Install the peer dependencies that match the adapter you want to use and pass
5859
the exported `components` object to `Builder`.
@@ -103,8 +104,31 @@ export const MyAntdBuilder = () => {
103104
};
104105
```
105106

107+
Fluent UI example:
108+
109+
```bash
110+
npm install @fluentui/react@^8.125.6
111+
```
112+
113+
```tsx
114+
import React from 'react';
115+
import { Builder } from '@vojtechportes/react-query-builder';
116+
import { components } from '@vojtechportes/react-query-builder/fluentui/v8';
117+
118+
export const MyFluentUiBuilder = () => {
119+
return (
120+
<Builder
121+
fields={fields}
122+
data={data}
123+
components={components}
124+
onChange={setData}
125+
/>
126+
);
127+
};
128+
```
129+
106130
`ThemeProvider` customizes the built-in default component set. It does not
107-
theme the MUI or ANTD adapters, which keep their styling in their host UI
131+
theme the MUI, ANTD, or Fluent UI adapters, which keep their styling in their host UI
108132
libraries.
109133

110134
More adapter details:

example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"@ant-design/icons": "^6.1.0",
1212
"@emotion/react": "^11.14.0",
1313
"@emotion/styled": "^11.14.1",
14+
"@fluentui/react": "^8.125.6",
1415
"@mui/icons-material": "^9.0.1",
1516
"@mui/material": "^9.0.1",
1617
"antd": "^6.0.0",

example/public/sitemap.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@
3636
<url>
3737
<loc>https://vojtechportes.github.io/react-query-builder/documentation/adapters</loc>
3838
</url>
39+
<url>
40+
<loc>https://vojtechportes.github.io/react-query-builder/documentation/adapters/mui</loc>
41+
</url>
42+
<url>
43+
<loc>https://vojtechportes.github.io/react-query-builder/documentation/adapters/antd</loc>
44+
</url>
45+
<url>
46+
<loc>https://vojtechportes.github.io/react-query-builder/documentation/adapters/fluentui</loc>
47+
</url>
3948
<url>
4049
<loc>https://vojtechportes.github.io/react-query-builder/documentation/theming</loc>
4150
</url>
@@ -60,6 +69,15 @@
6069
<url>
6170
<loc>https://vojtechportes.github.io/react-query-builder/api/adapters</loc>
6271
</url>
72+
<url>
73+
<loc>https://vojtechportes.github.io/react-query-builder/api/adapters/mui</loc>
74+
</url>
75+
<url>
76+
<loc>https://vojtechportes.github.io/react-query-builder/api/adapters/antd</loc>
77+
</url>
78+
<url>
79+
<loc>https://vojtechportes.github.io/react-query-builder/api/adapters/fluentui</loc>
80+
</url>
6381
<url>
6482
<loc>https://vojtechportes.github.io/react-query-builder/api/theming</loc>
6583
</url>

example/src/app/app.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export const App: React.FC = () => (
4343
<Route path="/api/builder-props" element={<Navigate to="/api/builder" replace />} />
4444
<Route path="/api/components" element={<ApiPage />} />
4545
<Route path="/api/adapters" element={<ApiPage />} />
46+
<Route path="/api/adapters/mui" element={<ApiPage />} />
47+
<Route path="/api/adapters/antd" element={<ApiPage />} />
48+
<Route path="/api/adapters/fluentui" element={<ApiPage />} />
4649
<Route path="/api/theming" element={<ApiPage />} />
4750
<Route path="/api/format-query" element={<ApiPage />} />
4851
<Route path="/api/parse-query" element={<ApiPage />} />
@@ -60,6 +63,12 @@ export const App: React.FC = () => (
6063
/>
6164
<Route path="/documentation/components" element={<DocumentationPage />} />
6265
<Route path="/documentation/adapters" element={<DocumentationPage />} />
66+
<Route path="/documentation/adapters/mui" element={<DocumentationPage />} />
67+
<Route path="/documentation/adapters/antd" element={<DocumentationPage />} />
68+
<Route
69+
path="/documentation/adapters/fluentui"
70+
element={<DocumentationPage />}
71+
/>
6372
<Route
6473
path="/documentation/parsing-and-formatting"
6574
element={<DocumentationPage />}

example/src/components/demo-playground.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
type DenormalizedQuery,
66
} from '@vojtechportes/react-query-builder';
77
import { components as antdComponents } from '@vojtechportes/react-query-builder/antd/v6';
8+
import { components as fluentUiComponents } from '@vojtechportes/react-query-builder/fluentui/v8';
89
import { createMonacoComponents } from '@vojtechportes/react-query-builder/monaco';
910
import { components as muiComponents } from '@vojtechportes/react-query-builder/mui/v9';
1011
import type { IColors } from '../../../src/constants/colors';
@@ -211,7 +212,8 @@ export const DemoPlayground: React.FC<IDemoPlaygroundProps> = ({
211212
const [showSourceCode, setShowSourceCode] = React.useState(false);
212213
const isMuiMode = customizationMode === 'mui';
213214
const isAntdMode = customizationMode === 'antd';
214-
const usesAdapterMode = isMuiMode || isAntdMode;
215+
const isFluentUiMode = customizationMode === 'fluentui';
216+
const usesAdapterMode = isMuiMode || isAntdMode || isFluentUiMode;
215217

216218
React.useEffect(() => {
217219
if (!singleRootGroup && textMode) {
@@ -225,6 +227,8 @@ export const DemoPlayground: React.FC<IDemoPlaygroundProps> = ({
225227
? muiComponents
226228
: customizationMode === 'antd'
227229
? antdComponents
230+
: customizationMode === 'fluentui'
231+
? fluentUiComponents
228232
: undefined;
229233

230234
if (!useMonacoTextEditor) {
@@ -469,6 +473,16 @@ export const DemoPlayground: React.FC<IDemoPlaygroundProps> = ({
469473
/>
470474
<span>ANTD adapter</span>
471475
</ToggleRow>
476+
477+
<ToggleRow>
478+
<Toggle
479+
type="radio"
480+
name="customization-mode"
481+
checked={customizationMode === 'fluentui'}
482+
onChange={() => setCustomizationMode('fluentui')}
483+
/>
484+
<span>Fluent UI adapter</span>
485+
</ToggleRow>
472486
</ChoiceGroup>
473487
</Panel>
474488

@@ -481,6 +495,8 @@ export const DemoPlayground: React.FC<IDemoPlaygroundProps> = ({
481495
usesAdapterMode
482496
? isMuiMode
483497
? 'ThemeProvider colors style the default builder components only. The MUI adapter uses Material UI styling instead.'
498+
: isFluentUiMode
499+
? 'ThemeProvider colors style the default builder components only. The Fluent UI adapter uses Fluent UI styling instead.'
484500
: 'ThemeProvider colors style the default builder components only. The ANTD adapter uses Ant Design styling instead.'
485501
: undefined
486502
}
@@ -509,6 +525,8 @@ export const DemoPlayground: React.FC<IDemoPlaygroundProps> = ({
509525
<BuilderSurface>
510526
{isMuiMode ? (
511527
<Builder {...builderProps} />
528+
) : isFluentUiMode ? (
529+
<Builder {...builderProps} />
512530
) : isAntdMode ? (
513531
<Builder {...builderProps} />
514532
) : (

example/src/components/documentation-sidebar.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { siteTheme } from '../constants/site-theme';
66
export interface INavigationPage {
77
path: string;
88
title: string;
9+
depth?: number;
910
}
1011

1112
export interface INavigationGroup {
@@ -46,16 +47,17 @@ const GroupTitle = styled.h3`
4647
text-transform: uppercase;
4748
`;
4849

49-
const LinkItem = styled(NavLink)`
50+
const LinkItem = styled(NavLink)<{ $depth?: number }>`
5051
display: block;
51-
padding: 0.38rem 0.55rem;
52+
padding: 0.38rem 0.55rem 0.38rem
53+
${({ $depth = 0 }) => `calc(0.55rem + ${$depth}rem)`};
5254
border-radius: 14px;
5355
color: #475569;
5456
line-height: 1.3;
5557
5658
&.active {
5759
margin: 0 -4px;
58-
padding-left: calc(0.55rem + 4px);
60+
padding-left: ${({ $depth = 0 }) => `calc(0.55rem + 4px + ${$depth}rem)`};
5961
padding-right: calc(0.55rem + 4px);
6062
background: ${siteTheme.primarySurfaceStrong};
6163
color: ${siteTheme.primaryDark};
@@ -75,14 +77,14 @@ export const DocumentationSidebar: React.FC<IDocumentationSidebarProps> = ({
7577
groups,
7678
}) => (
7779
<Root>
78-
<LinkItem to={overviewPage.path} end>
80+
<LinkItem to={overviewPage.path} end $depth={overviewPage.depth}>
7981
{overviewPage.title}
8082
</LinkItem>
8183
{groups.map(group => (
8284
<Group key={group.key}>
8385
<GroupTitle>{group.title}</GroupTitle>
8486
{group.pages.map(page => (
85-
<LinkItem key={page.path} to={page.path} end>
87+
<LinkItem key={page.path} to={page.path} end $depth={page.depth}>
8688
{page.title}
8789
</LinkItem>
8890
))}

0 commit comments

Comments
 (0)