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(calendar): expose weekdayTicks prop on TimeRange component #1634

Merged
merged 6 commits into from
Jun 28, 2021
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
2 changes: 2 additions & 0 deletions packages/calendar/src/TimeRange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const InnerTimeRange = ({
monthLegendPosition = timeRangeDefaultProps.monthLegendPosition,

weekdayLegendOffset = timeRangeDefaultProps.weekdayLegendOffset,
weekdayTicks,

dayBorderColor = timeRangeDefaultProps.dayBorderColor,
dayBorderWidth = timeRangeDefaultProps.dayBorderWidth,
Expand Down Expand Up @@ -105,6 +106,7 @@ const InnerTimeRange = ({
cellHeight,
cellWidth,
daySpacing,
ticks: weekdayTicks,
})

const monthLegends = useMonthLegends({
Expand Down
1 change: 1 addition & 0 deletions packages/calendar/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ export type TimeRangeSvgProps = Dimensions & { data: CalendarDatum[] } & Partial
square: boolean
role: string
weekdayLegendOffset: number
weekdayTicks: Array<0 | 1 | 2 | 3 | 4 | 5 | 6>
}
>

Expand Down
4 changes: 3 additions & 1 deletion packages/calendar/stories/timeRange.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ stories.add('responsive', () => {
translateY: -30,
},
]}
weekdayTicks={[]} // hide weekday tickmarks
{...{
dayRadius: number('dayRadius', 5),
formatValue: value => value,
Expand All @@ -96,7 +97,7 @@ stories.add('TimeRange vertical', () => {
{...{
dayRadius: 5,
margin: {
top: number('margin-top', 40),
top: number('margin-top', 48),
right: number('margin-right', 40),
bottom: number('margin-bottom', 40),
left: number('margin-left', 40),
Expand All @@ -105,6 +106,7 @@ stories.add('TimeRange vertical', () => {
daySpacing: number('daySpacing', 10),
}}
weekdayLegendOffset={0}
weekdayTicks={[0, 2, 4, 6]} // custom weekday tickmarks
height={number('height', 900)}
width={number('width', 250)}
direction="vertical"
Expand Down
32 changes: 18 additions & 14 deletions website/src/data/components/time-range/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,6 @@ const props = [
type: 'object[]',
required: true,
},
{
key: 'from',
group: 'Base',
help: 'start date',
type: 'string | Date',
required: true,
},
{
key: 'to',
group: 'Base',
help: 'end date',
type: 'string | Date',
required: true,
},
brammitch marked this conversation as resolved.
Show resolved Hide resolved
{
key: 'width',
enableControlForFlavors: ['api'],
Expand Down Expand Up @@ -228,6 +214,24 @@ const props = [
max: 100,
},
},
{
key: 'weekdayTicks',
help: 'define weekday tickmarks to show',
type: 'Array<0 | 1 | 2 | 3 | 4 | 5 | 6>',
required: false,
defaultValue: [1, 3, 5],
group: 'Weekday',
description: `
Array of weekday tickmarks to display:\n
0 = Sunday\n
1 = Monday\n
2 = Tuesday\n
3 = Wednesday\n
4 = Thursday\n
5 = Friday\n
6 = Saturday\n
`,
},
// Days
{
key: 'square',
Expand Down