Skip to content

Commit

Permalink
feat(calendar): expose weekdayTicks prop on TimeRange component (#1634)
Browse files Browse the repository at this point in the history
  • Loading branch information
brammitch committed Jun 28, 2021
1 parent f04e9ea commit efafa01
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
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,
},
{
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

0 comments on commit efafa01

Please sign in to comment.