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

feat(plasma-new-hope): Add calendar with new architecture #821

Merged
merged 8 commits into from
Nov 3, 2023
Merged
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
50 changes: 36 additions & 14 deletions packages/plasma-b2c/api/plasma-b2c.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,13 @@ import { ButtonSizes } from '@salutejs/plasma-hope';
import { ButtonView } from '@salutejs/plasma-hope';
import { ButtonViewProps } from '@salutejs/plasma-core';
import { buttonViews } from '@salutejs/plasma-hope';
import { Calendar } from '@salutejs/plasma-hope';
import { CalendarBase } from '@salutejs/plasma-hope';
import { CalendarBaseProps } from '@salutejs/plasma-hope';
import { CalendarBaseRange } from '@salutejs/plasma-hope';
import { CalendarDouble } from '@salutejs/plasma-hope';
import { CalendarDoubleProps } from '@salutejs/plasma-hope';
import { CalendarDoubleRange } from '@salutejs/plasma-hope';
import { CalendarProps } from '@salutejs/plasma-hope';
import { CalendarStateType } from '@salutejs/plasma-hope';
import { Calendar as Calendar_2 } from '@salutejs/plasma-new-hope/types/components/Calendar/Calendar.types';
import { CalendarBaseProps } from '@salutejs/plasma-new-hope/styled-components';
import { CalendarDoubleProps } from '@salutejs/plasma-new-hope/styled-components';
import { CalendarProps } from '@salutejs/plasma-new-hope/styled-components';
import { CalendarProps as CalendarProps_2 } from '@salutejs/plasma-new-hope';
import { CalendarRange } from '@salutejs/plasma-new-hope/types/components/Calendar/Calendar.types';
import { CalendarStateType } from '@salutejs/plasma-new-hope/styled-components';
import { canUseDOM } from '@salutejs/plasma-core';
import { Caption } from '@salutejs/plasma-hope';
import { Card } from '@salutejs/plasma-hope';
Expand All @@ -88,6 +86,7 @@ import { ColCount } from '@salutejs/plasma-hope';
import { ColOffsetProps } from '@salutejs/plasma-hope';
import { ColProps } from '@salutejs/plasma-hope';
import { ColSizeProps } from '@salutejs/plasma-hope';
import { Component } from 'react';
import { Container } from '@salutejs/plasma-hope';
import { ContainerProps } from '@salutejs/plasma-hope';
import { convertRoundnessMatrix } from '@salutejs/plasma-core';
Expand All @@ -114,6 +113,7 @@ import { ElasticGridProps } from '@salutejs/plasma-hope';
import { endAnimationClass } from '@salutejs/plasma-hope';
import { endTransitionClass } from '@salutejs/plasma-hope';
import { extractTextFrom } from '@salutejs/plasma-core';
import { FC } from 'react';
import { Filter } from '@salutejs/plasma-new-hope/types/engines/types';
import { FocusProps } from '@salutejs/plasma-core';
import { Footnote1 } from '@salutejs/plasma-hope';
Expand Down Expand Up @@ -202,6 +202,7 @@ import { RadioGroup } from '@salutejs/plasma-new-hope/styled-components';
import { radiuses } from '@salutejs/plasma-core';
import { Ratio } from '@salutejs/plasma-hope';
import { default as React_2 } from 'react';
import { ReactElement } from 'react';
import { RectSkeleton } from '@salutejs/plasma-hope';
import { RectSkeletonProps } from '@salutejs/plasma-hope';
import { RefAttributes } from 'react';
Expand Down Expand Up @@ -398,19 +399,40 @@ export { ButtonView }

export { buttonViews }

export { Calendar }
// @public (undocumented)
export const Calendar: FC<CalendarProps_2>;

export { CalendarBase }
// @public (undocumented)
export const CalendarBase: FunctionComponent<PropsType< {
view: {
primary: string;
};
size: {
m: string;
};
}> & HTMLAttributes<HTMLDivElement> & Calendar_2 & {
type?: "Days" | "Months" | "Years" | undefined;
} & RefAttributes<HTMLDivElement>>;

export { CalendarBaseProps }

export { CalendarBaseRange }
// @public (undocumented)
export const CalendarBaseRange: ({ value, disabledList, eventList, min, max, onChangeValue, ...rest }: CalendarRange<CalendarBaseProps>) => ReactElement<CalendarBaseProps, string | ((props: any) => ReactElement<any, any> | null) | (new (props: any) => Component<any, any, any>)>;

export { CalendarDouble }
// @public (undocumented)
export const CalendarDouble: FunctionComponent<PropsType< {
view: {
primary: string;
};
size: {
m: string;
};
}> & HTMLAttributes<HTMLDivElement> & Calendar_2 & RefAttributes<HTMLDivElement>>;

export { CalendarDoubleProps }

export { CalendarDoubleRange }
// @public (undocumented)
export const CalendarDoubleRange: ({ value, disabledList, eventList, min, max, onChangeValue, ...rest }: CalendarRange<CalendarDoubleProps>) => ReactElement<CalendarDoubleProps, string | ((props: any) => ReactElement<any, any> | null) | (new (props: any) => Component<any, any, any>)>;

export { CalendarProps }

Expand Down
27 changes: 27 additions & 0 deletions packages/plasma-b2c/src/components/Calendar/Calendar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {
boundCalendar,
withRange,
calendarBaseConfig,
calendarDoubleConfig,
component,
mergeConfig,
} from '@salutejs/plasma-new-hope/styled-components';
import type { CalendarBaseProps, CalendarDoubleProps } from '@salutejs/plasma-new-hope/styled-components';

import { config as baseConfig } from './CalendarBase.config';
import { config as doubleConfig } from './CalendarDouble.config';

const mergedCalendarBaseConfig = mergeConfig(calendarBaseConfig, baseConfig);
const mergedCalendarDoubleConfig = mergeConfig(calendarDoubleConfig, doubleConfig);

export const CalendarBase = component(mergedCalendarBaseConfig);
export const CalendarDouble = component(mergedCalendarDoubleConfig);
export const CalendarBaseRange = withRange<CalendarBaseProps>(CalendarBase);
export const CalendarDoubleRange = withRange<CalendarDoubleProps>(CalendarDouble);

export const Calendar = boundCalendar({
base: CalendarBase,
baseRange: CalendarBaseRange,
double: CalendarDouble,
doubleRange: CalendarDoubleRange,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { css, calendarBaseTokens } from '@salutejs/plasma-new-hope/styled-components';

export const config = {
defaults: {
view: 'primary',
size: 'm',
},
variations: {
view: {
primary: css`
${calendarBaseTokens.calendarBackgroundColor}: transparent;
${calendarBaseTokens.calendarSelectedItemBackground}: var(--plasma-colors-primary);
${calendarBaseTokens.calendarSelectedItemColor}: var(--plasma-colors-background-primary);
${calendarBaseTokens.calendarSelectableItemBackgroundHover}: var(--plasma-colors-surface-liquid02);
${calendarBaseTokens.calendarCurrentItemBorderColor}: var(--plasma-colors-primary);
${calendarBaseTokens.calendarCurrentItemBackgroundHover}: transparent;
${calendarBaseTokens.calendarCurrentItemColorHover}: var(--plasma-colors-primary);
${calendarBaseTokens.calendarCurrentItemChildBackgroundHover}: var(--plasma-colors-surface-liquid02);
${calendarBaseTokens.calendarActiveItemBackground}: var(--plasma-colors-primary);
${calendarBaseTokens.calendarActiveItemColor}: var(--plasma-colors-surface-solid03);
${calendarBaseTokens.calendarHoveredItemBackground}: var(--plasma-colors-accent);
${calendarBaseTokens.calendarHoveredItemColor}: var(--plasma-colors-background-primary);
${calendarBaseTokens.calendarRangeBackground}: var(--plasma-colors-surface-liquid02);
${calendarBaseTokens.calendarOutlineFocusColor}: var(--plasma-colors-button-focused);
${calendarBaseTokens.calendarContentPrimaryColor}: var(--plasma-colors-primary);
${calendarBaseTokens.calendarContentSecondaryColor}: var(--plasma-colors-secondary);
`,
},
size: {
m: css`
${calendarBaseTokens.calendarHeaderArrowContainerWidth}: 5.5rem;
${calendarBaseTokens.calendarItemBorderRadius}: 0.5rem;
${calendarBaseTokens.calendarHeaderFontFamily}: var(--plasma-typo-h4-font-family);
${calendarBaseTokens.calendarHeaderFontSize}: var(--plasma-typo-h4-font-size);
${calendarBaseTokens.calendarHeaderFontStyle}: var(--plasma-typo-h4-font-style);
${calendarBaseTokens.calendarHeaderFontLetterSpacing}: var(--plasma-typo-h4-letter-spacing);
${calendarBaseTokens.calendarHeaderFontLineHeight}: var(--plasma-typo-h4-line-height);
${calendarBaseTokens.calendarHeaderFontWeight}: var(--plasma-typo-h4-font-weight);
${calendarBaseTokens.calendarHeaderFontWeightBold}: var(--plasma-typo-h4-bold-font-weight);
${calendarBaseTokens.calendarYearFontFamily}: var(--plasma-typo-body-s-font-family);
${calendarBaseTokens.calendarYearFontSize}: var(--plasma-typo-body-s-font-size);
${calendarBaseTokens.calendarYearFontStyle}: var(--plasma-typo-body-s-font-style);
${calendarBaseTokens.calendarYearFontLetterSpacing}: var(--plasma-typo-body-s-letter-spacing);
${calendarBaseTokens.calendarYearFontLineHeight}: var(--plasma-typo-body-s-line-height);
${calendarBaseTokens.calendarYearFontWeight}: var(--plasma-typo-body-s-font-weight);
${calendarBaseTokens.calendarMonthFontFamily}: var(--plasma-typo-body-s-font-family);
${calendarBaseTokens.calendarMonthFontSize}: var(--plasma-typo-body-s-font-size);
${calendarBaseTokens.calendarMonthFontStyle}: var(--plasma-typo-body-s-font-style);
${calendarBaseTokens.calendarMonthFontLetterSpacing}: var(--plasma-typo-body-s-letter-spacing);
${calendarBaseTokens.calendarMonthFontLineHeight}: var(--plasma-typo-body-s-line-height);
${calendarBaseTokens.calendarMonthFontWeight}: var(--plasma-typo-body-s-font-weight);
${calendarBaseTokens.calendarDayFontFamily}: var(--plasma-typo-body-s-font-family);
${calendarBaseTokens.calendarDayFontSize}: var(--plasma-typo-body-s-font-size);
${calendarBaseTokens.calendarDayFontStyle}: var(--plasma-typo-body-s-font-style);
${calendarBaseTokens.calendarDayFontLetterSpacing}: var(--plasma-typo-body-s-letter-spacing);
${calendarBaseTokens.calendarDayFontLineHeight}: var(--plasma-typo-body-s-line-height);
${calendarBaseTokens.calendarDayFontWeight}: var(--plasma-typo-body-s-font-weight);
`,
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { css, calendarDoubleTokens } from '@salutejs/plasma-new-hope/styled-components';

export const config = {
defaults: {
view: 'primary',
size: 'm',
},
variations: {
view: {
primary: css`
${calendarDoubleTokens.calendarBackgroundColor}: transparent;
${calendarDoubleTokens.calendarSelectedItemBackground}: var(--plasma-colors-primary);
${calendarDoubleTokens.calendarSelectedItemColor}: var(--plasma-colors-background-primary);
${calendarDoubleTokens.calendarSelectableItemBackgroundHover}: var(--plasma-colors-surface-liquid02);
${calendarDoubleTokens.calendarCurrentItemBorderColor}: var(--plasma-colors-primary);
${calendarDoubleTokens.calendarCurrentItemBackgroundHover}: transparent;
${calendarDoubleTokens.calendarCurrentItemColorHover}: var(--plasma-colors-primary);
${calendarDoubleTokens.calendarCurrentItemChildBackgroundHover}: var(--plasma-colors-surface-liquid02);
${calendarDoubleTokens.calendarActiveItemBackground}: var(--plasma-colors-primary);
${calendarDoubleTokens.calendarActiveItemColor}: var(--plasma-colors-surface-solid03);
${calendarDoubleTokens.calendarHoveredItemBackground}: var(--plasma-colors-accent);
${calendarDoubleTokens.calendarHoveredItemColor}: var(--plasma-colors-background-primary);
${calendarDoubleTokens.calendarSeparatorBackground}: var(--plasma-colors-surface-liquid02);
${calendarDoubleTokens.calendarRangeBackground}: var(--plasma-colors-surface-liquid02);
${calendarDoubleTokens.calendarOutlineFocusColor}: var(--plasma-colors-button-focused);
${calendarDoubleTokens.calendarContentPrimaryColor}: var(--plasma-colors-primary);
${calendarDoubleTokens.calendarContentSecondaryColor}: var(--plasma-colors-secondary);
`,
},
size: {
m: css`
${calendarDoubleTokens.calendarItemBorderRadius}: 0.5rem;
${calendarDoubleTokens.calendarHeaderFontFamily}: var(--plasma-typo-h4-font-family);
${calendarDoubleTokens.calendarHeaderFontSize}: var(--plasma-typo-h4-font-size);
${calendarDoubleTokens.calendarHeaderFontStyle}: var(--plasma-typo-h4-font-style);
${calendarDoubleTokens.calendarHeaderFontLetterSpacing}: var(--plasma-typo-h4-letter-spacing);
${calendarDoubleTokens.calendarHeaderFontLineHeight}: var(--plasma-typo-h4-line-height);
${calendarDoubleTokens.calendarHeaderFontWeight}: var(--plasma-typo-h4-font-weight);
${calendarDoubleTokens.calendarHeaderFontWeightBold}: var(--plasma-typo-h4-bold-font-weight);
${calendarDoubleTokens.calendarYearFontFamily}: var(--plasma-typo-body-s-font-family);
${calendarDoubleTokens.calendarYearFontSize}: var(--plasma-typo-body-s-font-size);
${calendarDoubleTokens.calendarYearFontStyle}: var(--plasma-typo-body-s-font-style);
${calendarDoubleTokens.calendarYearFontLetterSpacing}: var(--plasma-typo-body-s-letter-spacing);
${calendarDoubleTokens.calendarYearFontLineHeight}: var(--plasma-typo-body-s-line-height);
${calendarDoubleTokens.calendarYearFontWeight}: var(--plasma-typo-body-s-font-weight);
${calendarDoubleTokens.calendarMonthFontFamily}: var(--plasma-typo-body-s-font-family);
${calendarDoubleTokens.calendarMonthFontSize}: var(--plasma-typo-body-s-font-size);
${calendarDoubleTokens.calendarMonthFontStyle}: var(--plasma-typo-body-s-font-style);
${calendarDoubleTokens.calendarMonthFontLetterSpacing}: var(--plasma-typo-body-s-letter-spacing);
${calendarDoubleTokens.calendarMonthFontLineHeight}: var(--plasma-typo-body-s-line-height);
${calendarDoubleTokens.calendarMonthFontWeight}: var(--plasma-typo-body-s-font-weight);
${calendarDoubleTokens.calendarDayFontFamily}: var(--plasma-typo-body-s-font-family);
${calendarDoubleTokens.calendarDayFontSize}: var(--plasma-typo-body-s-font-size);
${calendarDoubleTokens.calendarDayFontStyle}: var(--plasma-typo-body-s-font-style);
${calendarDoubleTokens.calendarDayFontLetterSpacing}: var(--plasma-typo-body-s-letter-spacing);
${calendarDoubleTokens.calendarDayFontLineHeight}: var(--plasma-typo-body-s-line-height);
${calendarDoubleTokens.calendarDayFontWeight}: var(--plasma-typo-body-s-font-weight);
`,
},
},
};
10 changes: 8 additions & 2 deletions packages/plasma-b2c/src/components/Calendar/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
export { Calendar, CalendarBase, CalendarBaseRange, CalendarDouble, CalendarDoubleRange } from '@salutejs/plasma-hope';
export type { CalendarProps, CalendarBaseProps, CalendarStateType, CalendarDoubleProps } from '@salutejs/plasma-hope';
export { Calendar, CalendarBase, CalendarBaseRange, CalendarDouble, CalendarDoubleRange } from './Calendar';

export type {
CalendarBaseProps,
CalendarDoubleProps,
CalendarProps,
CalendarStateType,
} from '@salutejs/plasma-new-hope/styled-components';
49 changes: 0 additions & 49 deletions packages/plasma-hope/api/plasma-hope.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,55 +397,6 @@ export const buttonWarningActive = "var(--plasma-colors-button-warning-active)";
// @public (undocumented)
export const buttonWarningHover = "var(--plasma-colors-button-warning-hover)";

// @public
export const Calendar: React_2.FC<CalendarProps>;

// @public
export const CalendarBase: React_2.FC<CalendarBaseProps>;

// Warning: (ae-forgotten-export) The symbol "Calendar_2" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export type CalendarBaseProps = Calendar_2 & {
type?: CalendarStateType;
};

// Warning: (ae-forgotten-export) The symbol "CalendarRange" needs to be exported by the entry point index.d.ts
//
// @public
export const CalendarBaseRange: ({ value, disabledList, eventList, min, max, onChangeValue, ...rest }: CalendarRange<CalendarBaseProps>) => React_2.ReactElement<CalendarBaseProps, string | ((props: any) => React_2.ReactElement<any, any> | null) | (new (props: any) => React_2.Component<any, any, any>)>;

// @public
export const CalendarDouble: React_2.FC<CalendarDoubleProps>;

// @public (undocumented)
export type CalendarDoubleProps = Calendar_2;

// @public
export const CalendarDoubleRange: ({ value, disabledList, eventList, min, max, onChangeValue, ...rest }: CalendarRange<Calendar_2>) => React_2.ReactElement<Calendar_2, string | ((props: any) => React_2.ReactElement<any, any> | null) | (new (props: any) => React_2.Component<any, any, any>)>;

// @public (undocumented)
export type CalendarProps = ({
isDouble?: false;
isRange?: false;
value: Date;
} & CalendarBaseProps) | ({
isDouble?: false;
isRange: true;
} & CalendarRange<CalendarBaseProps>) | ({
isDouble?: true;
isRange?: false;
value: Date;
} & CalendarDoubleProps) | ({
isDouble?: true;
isRange: true;
} & CalendarRange<CalendarDoubleProps>);

// Warning: (ae-forgotten-export) The symbol "CalendarState" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export type CalendarStateType = keyof typeof CalendarState;

export { canUseDOM }

export { Caption }
Expand Down
Loading
Loading