Skip to content

Commit

Permalink
prop for grid
Browse files Browse the repository at this point in the history
  • Loading branch information
kiley-mitti committed May 3, 2024
1 parent 5453785 commit 3082dd7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/web-components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20086,6 +20086,10 @@ export namespace Components {
* The timeline's playhead date time. Must be an ISO string "2021-02-02T05:00:00Z"
*/
"playhead"?: string;
/**
* Controls the display of grid lines
*/
"showGrid": boolean;
/**
* The timeline's start date. Must be an ISO string "2021-02-02T05:00:00Z"
*/
Expand Down Expand Up @@ -20173,6 +20177,7 @@ export namespace Components {
* The playhead of rux-track.
*/
"playhead": any;
"showGrid": boolean;
"start": string;
"timezone": string;
"width": number;
Expand Down Expand Up @@ -55713,6 +55718,10 @@ declare namespace LocalJSX {
* The timeline's playhead date time. Must be an ISO string "2021-02-02T05:00:00Z"
*/
"playhead"?: string;
/**
* Controls the display of grid lines
*/
"showGrid"?: boolean;
/**
* The timeline's start date. Must be an ISO string "2021-02-02T05:00:00Z"
*/
Expand Down Expand Up @@ -55804,6 +55813,7 @@ declare namespace LocalJSX {
* The playhead of rux-track.
*/
"playhead"?: any;
"showGrid"?: boolean;
"start"?: string;
"timezone"?: string;
"width"?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ export class RuxTimeline {
*/
@Prop() interval: 'month' | 'week' | 'hour' | 'day' | 'minute' = 'hour'

/**
* Controls the display of grid lines
*/
@Prop() showGrid: boolean = false

/**
* Controls the timezone that the timeline is localized to. Must be an IANA time zone name ("America/New_York") or an offset string.
*/
Expand Down Expand Up @@ -93,6 +98,7 @@ export class RuxTimeline {
@Watch('end')
@Watch('interval')
@Watch('timezone')
@Watch('showGrid')
handleChange() {
this.syncPlayhead()
this._updateRegions()
Expand Down Expand Up @@ -368,6 +374,7 @@ export class RuxTimeline {
el.start = useStartEndDates.timelineStart.toISOString()
el.end = useStartEndDates.timelineEnd.toISOString()
el.timezone = this.timezone
el.showGrid = this.showGrid
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ export class RuxTrack {
*/
@Prop({ reflect: true }) timezone = 'UTC'

/**
* @internal - The timeline's grid indicator. Set automatically from the parent Timeline component.
*/
@Prop({ reflect: true }) showGrid = false

/**
* The playhead of rux-track.
*/
Expand All @@ -81,6 +86,7 @@ export class RuxTrack {
@Watch('start')
@Watch('end')
@Watch('interval')
@Watch('showGrid')
handleUpdate(_newValue: any, old: any) {
if (old) {
this.initializeRows()
Expand Down Expand Up @@ -370,7 +376,7 @@ export class RuxTrack {
(this.playedIndicator = el as HTMLInputElement)
}
></div>
{this.renderGrid()}
{this.showGrid ? this.renderGrid() : null}
</div>
</Host>
)
Expand Down
8 changes: 8 additions & 0 deletions packages/web-components/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
icon="zoom-in"
onclick="zoom(1)"
></rux-button>
<rux-button secondary onclick="togglegrid()"
>Toggle Grid</rux-button
>
</section>

<rux-timeline
Expand All @@ -83,6 +86,7 @@
playhead="2021-02-02T00:00:00.000Z"
interval="hour"
zoom="2"
show-grid
>
<rux-track>
<div slot="label">Region 1</div>
Expand Down Expand Up @@ -172,6 +176,10 @@
timeline.setAttribute('zoom', zoomLevel)
}

const togglegrid = () => {
timeline.toggleAttribute('show-grid')
}

function setZoomInterval(zoomLevel) {
if (zoomLevel < 1) timeline.setAttribute('interval', 'month')
if (zoomLevel < 2) timeline.setAttribute('interval', 'week')
Expand Down

0 comments on commit 3082dd7

Please sign in to comment.