Skip to content

Commit

Permalink
feat(html): add ColorPalette sizing
Browse files Browse the repository at this point in the history
  • Loading branch information
inikolova committed Jan 8, 2025
1 parent 5eaebf2 commit 7e4897e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/html/src/coloreditor/color-editor.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const ColorEditor = (
</div>
</div>
<div className="k-coloreditor-views k-vstack">
{ view === 'gradient' ? <ColorGradient focus={focusView} size={size} canvasOrientation={canvasOrientation} /> : <ColorPalette palette={palette} /> }
{ view === 'gradient' ? <ColorGradient focus={focusView} size={size} canvasOrientation={canvasOrientation} /> : <ColorPalette palette={palette} size={size} /> }
</div>
{actionButtons && <ActionButtons className="k-coloreditor-footer" alignment="end" >
<Button className="k-coloreditor-cancel" size={size}>Cancel</Button>
Expand Down
17 changes: 13 additions & 4 deletions packages/html/src/colorpalette/colorpalette.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { classNames, stateClassNames, States } from '../misc';
import { classNames, stateClassNames, States, Size, optionClassNames } from '../misc';
import { ColorPaletteRow } from './colorpalette-row';
import { ColorPaletteTile } from './colorpalette-tile';

Expand All @@ -8,9 +8,15 @@ const states = [
States.disabled
];

const options = {};
const options = {
size: [ Size.small, Size.medium, Size.large ]
};

export type KendoColorPaletteOptions = {
size?: (typeof options.size)[number] | null;
};

export type KendoColorPaletteProps = {
export type KendoColorPaletteProps = KendoColorPaletteOptions & {
palette?: Array<string> | any;
columns?: number;
tileSize?: string;
Expand All @@ -19,7 +25,8 @@ export type KendoColorPaletteProps = {
export type KendoColorPaletteState = { [K in (typeof states)[number]]?: boolean };

const defaultOptions = {
columns: 10
columns: 10,
size: Size.medium
};

export const ColorPalette = (
Expand All @@ -28,6 +35,7 @@ export const ColorPalette = (
React.HTMLAttributes<HTMLDivElement>
) => {
const {
size = defaultOptions.size,
palette,
columns = defaultOptions.columns,
tileSize,
Expand Down Expand Up @@ -69,6 +77,7 @@ export const ColorPalette = (
stateClassNames(COLORPALETTE_CLASSNAME, {
disabled,
}),
optionClassNames(COLORPALETTE_CLASSNAME, { size }),
)}>

<table className="k-colorpalette-table">
Expand Down
21 changes: 21 additions & 0 deletions packages/html/src/colorpalette/tests/colorpalette-size.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ColorPalette, ColorPaletteNormal } from '../../colorpalette';

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

<span>Small</span>
<span>Medium</span>
<span>Large</span>

{ ColorPalette.options.size.map((size) => (
<>
<section>
<ColorPaletteNormal size={size} />
</section>
</>
))}

</div>
</>
);

0 comments on commit 7e4897e

Please sign in to comment.