Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prototype: add Scaffold #5869

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
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;

Check warning on line 8 in packages/vkui/src/components/Scaffold/Scaffold.tsx

View check run for this annotation

Codecov / codecov/patch

packages/vkui/src/components/Scaffold/Scaffold.tsx#L7-L8

Added lines #L7 - L8 were not covered by tests
}

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

Check warning on line 12 in packages/vkui/src/components/Scaffold/Scaffold.tsx

View check run for this annotation

Codecov / codecov/patch

packages/vkui/src/components/Scaffold/Scaffold.tsx#L11-L12

Added lines #L11 - L12 were not covered by tests
}

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

Check warning on line 16 in packages/vkui/src/components/Scaffold/Scaffold.tsx

View check run for this annotation

Codecov / codecov/patch

packages/vkui/src/components/Scaffold/Scaffold.tsx#L15-L16

Added lines #L15 - L16 were not covered by tests
}

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

Check warning on line 20 in packages/vkui/src/components/Scaffold/Scaffold.tsx

View check run for this annotation

Codecov / codecov/patch

packages/vkui/src/components/Scaffold/Scaffold.tsx#L19-L20

Added lines #L19 - L20 were not covered by tests
}

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

export const Scaffold = ({ topBar, children, bottomBar, ...restProps }: ScaffoldProps) => {
return (

Check warning on line 29 in packages/vkui/src/components/Scaffold/Scaffold.tsx

View check run for this annotation

Codecov / codecov/patch

packages/vkui/src/components/Scaffold/Scaffold.tsx#L28-L29

Added lines #L28 - L29 were not covered by tests
<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
Loading