Skip to content

Commit

Permalink
feat(*): add disabled opacity token in calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
iljs committed Nov 22, 2024
1 parent 291ea03 commit f8faf24
Show file tree
Hide file tree
Showing 21 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const config = {
${calendarBaseTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarBaseTokens.calendarHeaderArrowColor}: ${calendarBaseTokens.calendarContentPrimaryColor};
${calendarBaseTokens.calendarDayOfWeekColor}: var(--text-secondary);
${calendarBaseTokens.calendarDisabledOpacity}: 0.4;
${calendarBaseTokens.iconButtonColor}: var(--text-primary);
${calendarBaseTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const config = {
${calendarDoubleTokens.calendarContentPrimaryColor}: var(--surface-solid-default);
${calendarDoubleTokens.calendarHeaderArrowColor}: ${calendarDoubleTokens.calendarContentPrimaryColor};
${calendarDoubleTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarDoubleTokens.calendarDisabledOpacity}: 0.4;
${calendarDoubleTokens.iconButtonColor}: var(--text-primary);
${calendarDoubleTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,5 @@ export const tokens = {
calendarOutlineFocusColor: '--plasma-calendar-outline-focus-color',
calendarContentPrimaryColor: '--plasma-calendar-content-primary-color',
calendarContentSecondaryColor: '--plasma-calendar-content-secondary-color',
calendarDisabledOpacity: '--plasma-calendar-disabled-opacity',
};
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const StyledItem = styled.div<{ offset: number }>`

const disabledItem = () => `
cursor: not-allowed;
opacity: 0.4;
opacity: var(${tokens.calendarDisabledOpacity});
`;

const disabledCurrentItem = () => `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const config = {
${calendarBaseTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarBaseTokens.calendarHeaderArrowColor}: ${calendarBaseTokens.calendarContentPrimaryColor};
${calendarBaseTokens.calendarDayOfWeekColor}: var(--text-secondary);
${calendarBaseTokens.calendarDisabledOpacity}: 0.4;
${calendarBaseTokens.iconButtonColor}: var(--text-primary);
${calendarBaseTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const config = {
${calendarDoubleTokens.calendarContentPrimaryColor}: var(--surface-solid-default);
${calendarDoubleTokens.calendarHeaderArrowColor}: ${calendarDoubleTokens.calendarContentPrimaryColor};
${calendarDoubleTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarDoubleTokens.calendarDisabledOpacity}: 0.4;
${calendarDoubleTokens.iconButtonColor}: var(--text-primary);
${calendarDoubleTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const config = {
${calendarBaseTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarBaseTokens.calendarHeaderArrowColor}: ${calendarBaseTokens.calendarContentPrimaryColor};
${calendarBaseTokens.calendarDayOfWeekColor}: var(--text-secondary);
${calendarBaseTokens.calendarDisabledOpacity}: 0.4;
${calendarBaseTokens.iconButtonColor}: var(--text-primary);
${calendarBaseTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const config = {
${calendarDoubleTokens.calendarContentPrimaryColor}: var(--surface-solid-default);
${calendarDoubleTokens.calendarHeaderArrowColor}: ${calendarDoubleTokens.calendarContentPrimaryColor};
${calendarDoubleTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarDoubleTokens.calendarDisabledOpacity}: 0.4;
${calendarDoubleTokens.iconButtonColor}: var(--text-primary);
${calendarDoubleTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const config = {
${calendarBaseTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarBaseTokens.calendarHeaderArrowColor}: ${calendarBaseTokens.calendarContentPrimaryColor};
${calendarBaseTokens.calendarDayOfWeekColor}: var(--text-secondary);
${calendarBaseTokens.calendarDisabledOpacity}: 0.4;
${calendarBaseTokens.iconButtonColor}: var(--text-primary);
${calendarBaseTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const config = {
${calendarDoubleTokens.calendarContentPrimaryColor}: var(--surface-solid-default);
${calendarDoubleTokens.calendarHeaderArrowColor}: ${calendarDoubleTokens.calendarContentPrimaryColor};
${calendarDoubleTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarDoubleTokens.calendarDisabledOpacity}: 0.4;
${calendarDoubleTokens.iconButtonColor}: var(--text-primary);
${calendarDoubleTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export default meta;
type CalendarProps = ComponentProps<typeof Calendar>;
type CalendarBaseProps = ComponentProps<typeof CalendarBase>;
type CalendarBaseRangeProps = ComponentProps<typeof CalendarBaseRange>;
const eventColors = ['red', 'green', 'blue', 'purple'];
const defaultMinDate = new Date(2016, 6, 1);
const defaultMaxDate = new Date(2030, 11, 24);

Expand All @@ -67,8 +66,6 @@ const getBaseEvents = (type: 'days' | 'months' | 'quarters' | 'years', datesNumb
year: 2023,
};

const colorIndex = Math.floor(Math.random() * eventColors.length);

const events = [...new Array(datesNumber)].map((_, index) => {
const eventNumber = Math.floor(Math.random() * 3 + 1);
const day = type === 'days' ? baseDate.day + index : 1;
Expand All @@ -82,7 +79,7 @@ const getBaseEvents = (type: 'days' | 'months' | 'quarters' | 'years', datesNumb
const year = type === 'years' ? baseDate.year + index : baseDate.year;

return [...new Array(eventNumber)].map(() => {
return { date: new Date(year, month, day), color: eventColors[colorIndex] };
return { date: new Date(year, month, day), color: 'var(--text-warning)' };
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const config = {
${calendarBaseTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarBaseTokens.calendarDayOfWeekColor}: var(--text-secondary);
${calendarBaseTokens.calendarHeaderArrowColor}: var(--text-accent);
${calendarBaseTokens.calendarDisabledOpacity}: 1;
${calendarBaseTokens.iconButtonColor}: var(--text-accent);
${calendarBaseTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const config = {
${calendarDoubleTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarDoubleTokens.calendarDayOfWeekColor}: var(--text-secondary);
${calendarDoubleTokens.calendarHeaderArrowColor}: var(--text-accent);
${calendarDoubleTokens.calendarDisabledOpacity}: 1;
${calendarDoubleTokens.iconButtonColor}: var(--text-primary);
${calendarDoubleTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const config = {
${calendarBaseTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarBaseTokens.calendarHeaderArrowColor}: ${calendarBaseTokens.calendarContentPrimaryColor};
${calendarBaseTokens.calendarDayOfWeekColor}: var(--text-secondary);
${calendarBaseTokens.calendarDisabledOpacity}: 0.4;
${calendarBaseTokens.iconButtonColor}: var(--text-primary);
${calendarBaseTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const config = {
${calendarDoubleTokens.calendarContentPrimaryColor}: var(--surface-solid-default);
${calendarDoubleTokens.calendarHeaderArrowColor}: ${calendarDoubleTokens.calendarContentPrimaryColor};
${calendarDoubleTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarDoubleTokens.calendarDisabledOpacity}: 0.4;
${calendarDoubleTokens.iconButtonColor}: var(--text-primary);
${calendarDoubleTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const config = {
${calendarBaseTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarBaseTokens.calendarHeaderArrowColor}: ${calendarBaseTokens.calendarContentPrimaryColor};
${calendarBaseTokens.calendarDayOfWeekColor}: var(--text-secondary);
${calendarBaseTokens.calendarDisabledOpacity}: 0.4;
${calendarBaseTokens.iconButtonColor}: var(--text-primary);
${calendarBaseTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const config = {
${calendarDoubleTokens.calendarContentPrimaryColor}: var(--surface-solid-default);
${calendarDoubleTokens.calendarHeaderArrowColor}: ${calendarDoubleTokens.calendarContentPrimaryColor};
${calendarDoubleTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarDoubleTokens.calendarDisabledOpacity}: 0.4;
${calendarDoubleTokens.iconButtonColor}: var(--text-primary);
${calendarDoubleTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const config = {
${calendarBaseTokens.calendarContentPrimaryColor}: var(--surface-solid-default);
${calendarBaseTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarBaseTokens.calendarDayOfWeekColor}: var(--text-secondary);
${calendarBaseTokens.calendarDisabledOpacity}: 0.4;
${calendarBaseTokens.iconButtonColor}: var(--text-primary);
${calendarBaseTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const config = {
${calendarDoubleTokens.calendarOutlineFocusColor}: var(--surface-accent);
${calendarDoubleTokens.calendarContentPrimaryColor}: var(--surface-solid-default);
${calendarDoubleTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarDoubleTokens.calendarDisabledOpacity}: 0.4;
${calendarDoubleTokens.iconButtonColor}: var(--text-primary);
${calendarDoubleTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const config = {
${calendarBaseTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarBaseTokens.calendarHeaderArrowColor}: ${calendarBaseTokens.calendarContentPrimaryColor};
${calendarBaseTokens.calendarDayOfWeekColor}: var(--text-secondary);
${calendarBaseTokens.calendarDisabledOpacity}: 0.4;
${calendarBaseTokens.iconButtonColor}: var(--text-primary);
${calendarBaseTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const config = {
${calendarDoubleTokens.calendarContentPrimaryColor}: var(--surface-solid-default);
${calendarDoubleTokens.calendarHeaderArrowColor}: ${calendarDoubleTokens.calendarContentPrimaryColor};
${calendarDoubleTokens.calendarContentSecondaryColor}: var(--text-secondary);
${calendarDoubleTokens.calendarDisabledOpacity}: 0.4;
${calendarDoubleTokens.iconButtonColor}: var(--text-primary);
${calendarDoubleTokens.iconButtonBackgroundColor}: var(--surface-clear);
Expand Down

0 comments on commit f8faf24

Please sign in to comment.