Skip to content

Commit

Permalink
chore(toolbar): initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
TeyaVes committed Dec 9, 2024
1 parent cc44471 commit 291191e
Show file tree
Hide file tree
Showing 13 changed files with 334 additions and 14 deletions.
86 changes: 80 additions & 6 deletions packages/default/scss/toolbar/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,44 @@
flex-wrap: nowrap;
}

&.k-toolbar-scrollable {
flex-wrap: nowrap;
position: relative;

&::before {
content: '';
height: 100%;
width: 46px;
position: absolute;
inset-inline-start: 0;
z-index: 3;
}

&::after {
content: '';
height: 100%;
width: 46px;
position: absolute;
inset-inline-end: 0;
z-index: 3;
}

&.k-toolbar-scrollable-start::before {
display: none;
}

&.k-toolbar-scrollable-end::after {
display: none;
}
}

&.k-toolbar-scrollable-buttons {
&::before,
&::after {
display: none;
}
}

> * {
flex-shrink: 0;
display: inline-flex;
Expand Down Expand Up @@ -77,12 +115,6 @@
width: min-content;
}

// Overflow anchor
.k-toolbar-overflow-button {
margin-inline-start: auto;
}


// Separator
.k-separator,
.k-toolbar-separator {
Expand All @@ -93,6 +125,10 @@
align-self: center;
}

// Overflow separator
.k-toolbar-overflow-separator {
margin-inline-start: auto;
}

// Spacer
.k-toolbar-spacer {
Expand All @@ -109,6 +145,30 @@
}
}

.k-toolbar-items {
display: flex;
flex-flow: row nowrap;
gap: $kendo-toolbar-spacing;
align-items: center;
justify-content: flex-start;
flex: 1 1 auto;
overflow: hidden;
}

.k-toolbar-scrollable .k-toolbar-items {
overflow-x: auto;
scrollbar-width: none;

&::-webkit-scrollbar {
display: none;
}
}

.k-toolbar-popup .k-toolbar-items {
flex-wrap: wrap;
}


// Outline Toolbar
.k-toolbar-outline {
border-width: $kendo-toolbar-outline-border-width;
Expand Down Expand Up @@ -148,9 +208,23 @@
margin-inline-start: calc( #{$_spacing} * -1 );
}

&.k-toolbar-scrollable::before {
inset-inline-start: $_spacing;
}

> * > label {
margin-inline-end: $_spacing;
}

.k-toolbar-items {
gap: $_spacing;
}
}

.k-toolbar-popup-#{$size} .k-toolbar-items {
padding-block: $_padding-y;
padding-inline: $_padding-x;
gap: $_spacing;
}
}
// Remove once we decide to not size empty containers
Expand Down
23 changes: 23 additions & 0 deletions packages/default/scss/toolbar/_theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
$kendo-toolbar-gradient
);
@include box-shadow( $kendo-toolbar-shadow );

&.k-toolbar-scrollable {
&::before {
background: linear-gradient(90deg, $kendo-toolbar-bg, rgba(255, 255, 255, 0));
}

&::after {
background: linear-gradient(270deg, $kendo-toolbar-bg, rgba(255, 255, 255, 0));
}
}
}

// Outline Toolbar
Expand All @@ -58,6 +68,19 @@
}
}

.k-toolbar-outline,
.k-toolbar-flat {
&.k-toolbar-scrollable {
&::before {
background: linear-gradient(90deg, $kendo-toolbar-bg, rgba(255, 255, 255, 0));
}

&::after {
background: linear-gradient(270deg, $kendo-toolbar-bg, rgba(255, 255, 255, 0));
}
}
}

.k-floating-toolbar,
.editorToolbarWindow.k-window-content { // stylelint-disable-line
@include fill(
Expand Down
2 changes: 2 additions & 0 deletions packages/html/src/toolbar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ export * from './toolbar-item.spec';
export * from './toolbar-popup.spec';
export * from './templates/toolbar-normal';
export * from './templates/toolbar-resizable';
export * from './templates/toolbar-scrollable';
export * from './templates/toolbar-section';
2 changes: 2 additions & 0 deletions packages/html/src/toolbar/templates/toolbar-resizable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Button } from '../../button';
import { ButtonGroup } from '../../button-group';
import { MenuButton } from '../../menu-button';
import { SplitButton } from '../../split-button';
import { ToolbarSeparator } from "../toolbar-separator";

export const ToolbarResizable = (props) => (
<Toolbar resizable children={[
Expand All @@ -14,6 +15,7 @@ export const ToolbarResizable = (props) => (
<Button icon="align-center">Center</Button>
<Button className="k-group-end" icon="align-right">Right</Button>
</ButtonGroup>,
<ToolbarSeparator className="k-toolbar-overflow-separator" />,
<Button icon="more-vertical" className="k-toolbar-overflow-button" fillMode="flat" rounded={null}></Button>
]}
{...props}>
Expand Down
28 changes: 28 additions & 0 deletions packages/html/src/toolbar/templates/toolbar-scrollable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Toolbar } from "../toolbar.spec";
import { Button } from '../../button';
import { ButtonGroup } from '../../button-group';
import { MenuButton } from '../../menu-button';
import { SplitButton } from '../../split-button';

export const ToolbarScrollable = (props) => (
<Toolbar scrollable {...props} children={[
<Button key="toolbar-button">Button</Button>,
<MenuButton key="toolbar-menu-button" text="Menu button"></MenuButton>,
<SplitButton key="toolbar-split-button">Split button</SplitButton>,
<ButtonGroup key="toolbar-button-group">
<Button className="k-group-start" icon="align-left">Left</Button>
<Button icon="align-center">Center</Button>
<Button className="k-group-end" icon="align-right">Right</Button>
</ButtonGroup>,
<Button key="toolbar-button">Button</Button>,
<MenuButton key="toolbar-menu-button" text="Menu button"></MenuButton>,
<SplitButton key="toolbar-split-button">Split button</SplitButton>,
<ButtonGroup key="toolbar-button-group">
<Button className="k-group-start" icon="align-left">Left</Button>
<Button icon="align-center">Center</Button>
<Button className="k-group-end" icon="align-right">Right</Button>
</ButtonGroup>
]}
{...props}>
</Toolbar>
);
35 changes: 35 additions & 0 deletions packages/html/src/toolbar/templates/toolbar-section.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Toolbar } from "../toolbar.spec";
import { Button } from '../../button';
import { ButtonGroup } from '../../button-group';
import { MenuButton } from '../../menu-button';
import { SplitButton } from '../../split-button';
import { ToolbarSeparator } from "../toolbar-separator";
import ToolbarPopup from "../toolbar-popup.spec";

export const ToolbarSection = ({ fillMode, size, ...other }: any) => (
<>
<Toolbar section fillMode={fillMode} size={size} children={[
<Button key="toolbar-button" fillMode={fillMode} size={size}>Button</Button>,
<MenuButton key="toolbar-menu-button" fillMode={fillMode} size={size} text="Menu button"></MenuButton>,
<ButtonGroup key="toolbar-button-group" fillMode={fillMode}>
<Button className="k-group-start" icon="align-left" fillMode={fillMode} size={size}>Left</Button>
<Button icon="align-center" fillMode={fillMode} size={size}>Center</Button>
<Button className="k-group-end" icon="align-right" fillMode={fillMode} size={size}>Right</Button>
</ButtonGroup>,
<ToolbarSeparator className="k-toolbar-overflow-separator" />,
<Button icon="more-horizontal" className="k-toolbar-overflow-button" fillMode="flat" rounded={null}></Button>
]}
{...other}>
</Toolbar>
<ToolbarPopup size={size} section {...other} >
<SplitButton key="toolbar-split-button" fillMode={fillMode} size={size}>Split button</SplitButton>
<Button key="toolbar-button" fillMode={fillMode} size={size}>Button</Button>
<MenuButton key="toolbar-menu-button" text="Menu button" fillMode={fillMode} size={size}></MenuButton>
<ButtonGroup key="toolbar-button-group" fillMode={fillMode}>
<Button className="k-group-start" icon="align-left" fillMode={fillMode} size={size}>Left</Button>
<Button icon="align-center" fillMode={fillMode} size={size}>Center</Button>
<Button className="k-group-end" icon="align-right" fillMode={fillMode} size={size}>Right</Button>
</ButtonGroup>
</ToolbarPopup>
</>
);
3 changes: 2 additions & 1 deletion packages/html/src/toolbar/tests/toolbar-adaptive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Button } from '../../button';
import { ButtonGroup } from '../../button-group';
import { ActionSheet, ActionSheetHeader } from '../../action-sheet';
import { MenuItem, MenuSeparator, MenuList } from '../../menu';
import { ToolbarResizable } from '..';
import { ToolbarResizable, ToolbarSeparator } from '..';

const styles = `
#test-area {
Expand Down Expand Up @@ -32,6 +32,7 @@ export default () =>(
<Button size="large" icon="align-center">Center</Button>
<Button className="k-group-end" size="large" icon="align-right">Right</Button>
</ButtonGroup>
<ToolbarSeparator className="k-toolbar-overflow-separator" />
<Button size="large" icon="more-vertical" className="k-toolbar-overflow-button" fillMode="flat" rounded={null}></Button>
</ToolbarResizable>
<ActionSheet adaptive={true} overlay={false}>
Expand Down
40 changes: 40 additions & 0 deletions packages/html/src/toolbar/tests/toolbar-scrollable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { ToolbarScrollable } from '..';


export default () =>(
<>
<div id="test-area" className="k-d-grid k-grid-cols-2">

<span className="k-colspan-all k-col-span-full">Toolbar Buttons Around</span>
<section className="k-colspan-all k-col-span-full">
<ToolbarScrollable scrollButtons="around" />
</section>

<span className="k-colspan-all k-col-span-full">Toolbar Buttons Start</span>
<section className="k-colspan-all k-col-span-full">
<ToolbarScrollable scrollButtons="start" />
</section>

<span className="k-colspan-all k-col-span-full">Toolbar Buttons End</span>
<section className="k-colspan-all k-col-span-full">
<ToolbarScrollable scrollButtons="end" />
</section>

<span className="k-colspan-all k-col-span-full">Toolbar No Buttons Scroll Start</span>
<section className="k-colspan-all k-col-span-full">
<ToolbarScrollable scrollButtons="hidden" scrollingPosition="start"/>
</section>

<span className="k-colspan-all k-col-span-full">Toolbar No Buttons Scroll End</span>
<section className="k-colspan-all k-col-span-full">
<ToolbarScrollable scrollButtons="hidden" scrollingPosition="end" />
</section>

<span className="k-colspan-all k-col-span-full">RTL</span>
<section className="k-colspan-all k-col-span-full" dir="rtl">
<ToolbarScrollable />
</section>

</div>
</>
);
37 changes: 37 additions & 0 deletions packages/html/src/toolbar/tests/toolbar-section.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { ToolbarSection } from '../templates/toolbar-section';


const styles = `
.k-animation-container {
width: 100%;
}
.toolbar-popup-section {
position: relative;
height: 200px;
}
`;

export default () =>(
<>
<style>{styles}</style>
<div id="test-area" className="k-d-grid k-grid-cols-2">

<span className="k-colspan-full k-col-span-full">Toolbar Popup Section</span>
<section className="k-colspan-1 k-col-span-1 toolbar-popup-section">
<ToolbarSection />
</section>

<span className="k-colspan-full k-col-span-full">Toolbar Popup Section Flat</span>
<section className="k-colspan-1 k-col-span-1 toolbar-popup-section">
<ToolbarSection fillMode="flat" />
</section>

<span className="k-colspan-full k-col-span-full">Toolbar Popup Section</span>
<section className="k-colspan-1 k-col-span-1 toolbar-popup-section">
<ToolbarSection fillMode="outline" />
</section>

</div>
</>
);
1 change: 1 addition & 0 deletions packages/html/src/toolbar/tests/toolbar-sizes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default () =>(
<ColorPicker size={size} />
</ToolbarItem>
<Switch size={size} checked />
<ToolbarSeparator className="k-toolbar-overflow-separator" />
<Button size={size} icon="more-vertical" className="k-toolbar-overflow-button" fillMode="flat" rounded={null}></Button>
</ToolbarResizable>
</section>
Expand Down
6 changes: 6 additions & 0 deletions packages/html/src/toolbar/tests/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default () =>(
<ColorPicker />
</ToolbarItem>
<Switch checked />
<ToolbarSeparator className="k-toolbar-overflow-separator" />
<Button icon="more-vertical" className="k-toolbar-overflow-button" fillMode="flat" rounded={null}></Button>
</ToolbarResizable>
</section>
Expand All @@ -55,6 +56,7 @@ export default () =>(
<ColorPicker />
</ToolbarItem>
<Switch checked />
<ToolbarSeparator className="k-toolbar-overflow-separator" />
<Button icon="more-vertical" className="k-toolbar-overflow-button" fillMode="flat" rounded={null}></Button>
</ToolbarResizable>
</section>
Expand All @@ -76,6 +78,7 @@ export default () =>(
<Button icon="bold" active></Button>
<Button icon="bold" selected></Button>
<Button icon="bold" disabled></Button>
<ToolbarSeparator className="k-toolbar-overflow-separator" />
<Button icon="more-vertical" className="k-toolbar-overflow-button" fillMode="flat" rounded={null} hover></Button>
</ToolbarResizable>
</section>
Expand All @@ -87,6 +90,7 @@ export default () =>(
<Button icon="align-left" active>Active</Button>
<Button icon="align-left" selected>Selected</Button>
<Button icon="align-left" disabled>Disabled</Button>
<ToolbarSeparator className="k-toolbar-overflow-separator" />
<Button icon="more-vertical" className="k-toolbar-overflow-button" fillMode="flat" rounded={null} focus></Button>
</ToolbarResizable>
</section>
Expand All @@ -98,6 +102,7 @@ export default () =>(
<Button themeColor="primary" icon="align-left" active>Active</Button>
<Button themeColor="primary" icon="align-left" selected>Selected</Button>
<Button themeColor="primary" icon="align-left" disabled>Disabled</Button>
<ToolbarSeparator className="k-toolbar-overflow-separator" />
<Button icon="more-vertical" className="k-toolbar-overflow-button" fillMode="flat" rounded={null} active></Button>
</ToolbarResizable>
</section>
Expand All @@ -112,6 +117,7 @@ export default () =>(
<Button className="k-group-start" icon="align-left" disabled focus>Button 1</Button>
<Button className="k-group-end" icon="align-center" disabled>Button 2</Button>
</ButtonGroup>
<ToolbarSeparator className="k-toolbar-overflow-separator" />
<Button icon="more-vertical" className="k-toolbar-overflow-button" fillMode="flat" rounded={null} disabled focus></Button>
</ToolbarResizable>
</section>
Expand Down
Loading

0 comments on commit 291191e

Please sign in to comment.