Skip to content

Commit 4fb944d

Browse files
committed
Improved breakpoints
1 parent fa0dcf7 commit 4fb944d

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Piral Changelog
22

3+
## 1.8.3 (tbd)
4+
5+
- Updated `breakpoints` to have flexible breakpoints
6+
- Added `breakpoints` parameter to `getAppInstance` options
7+
- Added `breakpoints` parameter to `createInstanceElement` function
8+
39
## 1.8.2 (January 31, 2025)
410

511
- Fixed issue with command line parsing in the `piral-cli` on Windows

src/framework/piral-core/src/types/layout.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/**
22
* The mapping of breakpoints to layout type index.
3+
* Choose up to three breakpoints.
4+
* In case of no breakpoint a default layout will be chosen.
35
*/
4-
export type LayoutBreakpoints = [string, string, string];
6+
export type LayoutBreakpoints = [string?, string?, string?];
57

68
/**
79
* The different known layout types.

src/framework/piral/src/app.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ render(app, document.querySelector('#app'));
1919
```
2020
*/
2121
export function getAppInstance(config: PiralConfiguration = {}, options: PiralRenderBaseOptions = {}) {
22-
const { settings, layout, errors, dashboardPath, piralChildren } = options;
22+
const { settings, layout, errors, dashboardPath, piralChildren, breakpoints } = options;
2323
const instance = createPiral(config, settings);
24-
const app = createInstanceElement(instance, layout, errors, dashboardPath, piralChildren);
24+
const app = createInstanceElement(instance, layout, errors, dashboardPath, piralChildren, breakpoints);
2525
return { instance, app };
2626
}

src/framework/piral/src/instance.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ErrorComponentsState,
99
SetErrors,
1010
SetLayout,
11+
LayoutBreakpoints,
1112
} from 'piral-core';
1213

1314
export function createInstanceElement(
@@ -16,9 +17,10 @@ export function createInstanceElement(
1617
errors?: Partial<ErrorComponentsState>,
1718
dashboardPath = '/',
1819
piralChildren?: React.ReactNode,
20+
breakpoints?: LayoutBreakpoints,
1921
): React.ReactElement {
2022
return (
21-
<Piral instance={instance}>
23+
<Piral instance={instance} breakpoints={breakpoints}>
2224
<SetLayout layout={layout} />
2325
<SetErrors errors={errors} />
2426
<SetRoute path={dashboardPath} component={Dashboard} />

src/framework/piral/src/types.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ReactElement, ReactNode } from 'react';
2-
import { PiralConfiguration, ComponentsState, ErrorComponentsState } from 'piral-core';
2+
import { PiralConfiguration, ComponentsState, ErrorComponentsState, LayoutBreakpoints } from 'piral-core';
33
import { PiralExtSettings } from 'piral-ext';
44

55
/**
@@ -15,6 +15,10 @@ export interface PiralRenderBaseOptions {
1515
* Defines how the layout looks like.
1616
*/
1717
layout?: Partial<ComponentsState>;
18+
/**
19+
* Defines the breakpoints to use for responsive layouts.
20+
*/
21+
breakpoints?: LayoutBreakpoints;
1822
/**
1923
* Defines how the errors look like.
2024
*/

0 commit comments

Comments
 (0)