Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
53 changes: 53 additions & 0 deletions packages/vkui/src/components/Scaffold/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
```jsx { "props": { "layout": false, "adaptivity": true } }
const AdaptiveSpacingRenderer = () => {
const { sizeX } = useAdaptivityConditionalRender();

return (
<React.Fragment>
{sizeX.compact && <Separator className={sizeX.compact.className} />}
{sizeX.regular && <Spacing size={16} className={sizeX.regular.className} />}
</React.Fragment>
);
};

<Scaffold
topBar={
<PanelHeader fixed={false} separator={false}>
Scaffold Screen
</PanelHeader>
}
bottomBar={
<Tabbar style={{ position: 'static' }}>
<TabbarItem aria-label="Новости">
<Icon28NewsfeedOutline />
</TabbarItem>
<TabbarItem aria-label="Профиль">
<Icon28UserCircleOutline />
</TabbarItem>
</Tabbar>
}
>
<AdaptiveSpacingRenderer />
<Group>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
<SimpleCell>content</SimpleCell>
</Group>
</Scaffold>;
```
12 changes: 12 additions & 0 deletions packages/vkui/src/components/Scaffold/Scaffold.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.Scaffold__host {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
overflow: hidden;
}

.Scaffold__content {
flex-grow: 1;
overflow: auto;
}
36 changes: 36 additions & 0 deletions packages/vkui/src/components/Scaffold/Scaffold.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import { hasReactNode } from '@vkontakte/vkjs';
import { HasChildren, HasComponent } from '../../types';
import { RootComponent } from '../RootComponent/RootComponent';
import styles from './Scaffold.module.css';

function Wrapper<T extends HasChildren & HasComponent>({ Component = 'div', ...props }: T) {
return hasReactNode(props.children) ? <Component {...props} /> : null;
}

function TopBar(props: HasChildren) {
return <Wrapper {...props} />;
}

function Content(props: HasChildren) {
return <div className={styles['Scaffold__content']} {...props} />;
}

function BottomBar(props: HasChildren) {
return <Wrapper {...props} />;
}

export interface ScaffoldProps extends HasChildren {
topBar?: React.ReactNode;
bottomBar?: React.ReactNode;
}

export const Scaffold = ({ topBar, children, bottomBar, ...restProps }: ScaffoldProps) => {
return (
<RootComponent baseClassName={styles['Scaffold__host']} {...restProps}>
<TopBar>{topBar}</TopBar>
<Content>{children}</Content>
<BottomBar>{bottomBar}</BottomBar>
</RootComponent>
);
};
1 change: 1 addition & 0 deletions styleguide/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ const baseConfig = {
`../${VKUI_PACKAGE.PATHS.COMPONENTS_DIR}/FixedLayout/FixedLayout.tsx`,
`../${VKUI_PACKAGE.PATHS.COMPONENTS_DIR}/HorizontalScroll/HorizontalScroll.tsx`,
`../${VKUI_PACKAGE.PATHS.COMPONENTS_DIR}/AspectRatio/AspectRatio.tsx`,
`../${VKUI_PACKAGE.PATHS.COMPONENTS_DIR}/Scaffold/Scaffold.tsx`,
],
},
{
Expand Down