Skip to content
This repository has been archived by the owner on Oct 7, 2023. It is now read-only.

Commit

Permalink
refactor: normalize types definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Aarebecca committed Apr 9, 2023
1 parent 8726e2a commit b9023d0
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const NavigatorNull = () => {
nav.getContainer().appendChild(page);
});
nav.update({
initPage: 1,
defaultPage: 1,
x: 150,
y: 150,
pageWidth: 100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const NavigatorOverPages = () => {
style: {
x: 100,
y: 100,
initPage: 3,
defaultPage: 3,
pageWidth: 100,
pageHeight: 100,
loop: true,
Expand All @@ -57,13 +57,13 @@ export const NavigatorOverPages = () => {

timeout(() => {
nav.update({
initPage: 0,
defaultPage: 0,
});
}, 1000);

timeout(() => {
nav.update({
initPage: 4,
defaultPage: 4,
});
}, 2000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const NavigatorUpdate = () => {
// set page num
timeout(() => {
nav.update({
initPage: 4,
defaultPage: 4,
});
}, 3000);

Expand Down
8 changes: 4 additions & 4 deletions __tests__/integration/components/navigator/navigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ export const NavigatorDemo = () => {
nav3.next();
}, 1000);

const nav4 = createNav({ x: 650, y: 100, initPage: 3, orientation: 'vertical' });
const nav4 = createNav({ x: 650, y: 100, defaultPage: 3, orientation: 'vertical' });

timeout(() => {
nav4.next()?.finished.then(() => {
timeout(() => {
nav4.update({ initPage: 2 });
nav4.update({ defaultPage: 2 });
}, 1000);
});
}, 1000);

const nav5 = createNav({ x: 100, y: 250, initPage: 3 });
const nav5 = createNav({ x: 100, y: 250, defaultPage: 3 });

timeout(() => {
nav5.getContainer().destroyChildren();
Expand All @@ -90,7 +90,7 @@ export const NavigatorDemo = () => {
}, 1000);
}, 1000);

createNav({ x: 300, y: 250, initPage: 3, buttonTransform: 'scale(0.8)', pageNumFontSize: 14 }, 20);
createNav({ x: 300, y: 250, defaultPage: 3, buttonTransform: 'scale(0.8)', pageNumFontSize: 14 }, 20);
createNav({ x: 500, y: 250 }, 1);

return group;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const pageNavigator = new PageNavigator({
view: pages,
pageWidth,
pageHeight,
initPageNum: 1,
defaultPageNum: 1,
loop: false,
button: {
position: 'bottom',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const pageNavigator = new PageNavigator({
height: pageCount * pageHeight,
pageWidth,
pageHeight,
initPageNum: 1,
defaultPageNum: 1,
orientation: 'vertical',
loop: true,
button: {
Expand Down
6 changes: 3 additions & 3 deletions src/ui/legend/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ export type LabelStyleProps<T = any> = TextStyleProps &
direction?: 'positive' | 'negative';
filter?: (val: T, index: number, arr: T[]) => boolean;
formatter?: (val: T, index: number, arr: T[]) => string;
/** spacing between label and legend item */
/** spacing between label and legend ribbon */
spacing?: number;
};

export type IndicatorStyleProps<T = any> = PathStyleProps &
TextStyleProps & {
formatter: (val: T) => ExtendDisplayObject;
onIndicate: (val: T) => void;
indicate: (val: T) => void;
padding: SeriesAttr;
};

Expand All @@ -50,7 +50,7 @@ export type ContinuousStyleProps = LegendBaseStyleProps &
PrefixStyleProps<Partial<Omit<IndicatorStyleProps, 'text'>>, 'indicator'> &
PrefixStyleProps<Partial<Omit<LabelStyleProps, 'text'>>, 'label'> &
PrefixStyleProps<
Partial<Omit<RibbonStyleProps, 'orientation' | 'range' | 'partition' | 'size' | 'length'>>,
Partial<Omit<RibbonStyleProps, 'orientation' | 'range' | 'partition' | 'size' | 'length' | 'range'>>,
'ribbon'
> &
Partial<Pick<RibbonStyleProps, 'color' | 'block' | 'type'>> & {
Expand Down
6 changes: 3 additions & 3 deletions src/ui/navigator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class Navigator extends GUI<NavigatorStyleProps> {
controllerPadding: 5,
controllerSpacing: 5,
formatter: (curr, total) => `${curr}/${total}`,
initPage: 0,
defaultPage: 0,
loop: false,
orientation: 'horizontal',
pageNumFill: 'black',
Expand All @@ -70,8 +70,8 @@ export class Navigator extends GUI<NavigatorStyleProps> {
private playWindow = this.contentGroup.appendChild(new Group({ class: CLASS_NAMES.playWindow.name }));

private get defaultPage() {
const { initPage } = this.attributes;
return clamp(initPage, 0, Math.max(this.pageViews.length - 1, 0));
const { defaultPage } = this.attributes;
return clamp(defaultPage, 0, Math.max(this.pageViews.length - 1, 0));
}

private innerCurrPage: number = this.defaultPage;
Expand Down
5 changes: 3 additions & 2 deletions src/ui/navigator/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ export type NavigatorStyleProps = Omit<RectStyleProps, 'width' | 'height'> &
/** spacing between controller and page content */
controllerSpacing?: number;
formatter?: (curr: number, total: number) => string;
initPage?: number;
defaultPage?: number;
loop?: boolean;
orientation?: 'horizontal' | 'vertical';
/** once pageWidth is not provided, it will be set to bbox shape */ pageWidth?: number;
/** once pageWidth is not provided, it will be set to bbox shape */
pageWidth?: number;
/** infer to pageWidth */
pageHeight?: number;
};
Expand Down

0 comments on commit b9023d0

Please sign in to comment.