Skip to content

Commit

Permalink
change grid render to css background
Browse files Browse the repository at this point in the history
  • Loading branch information
kiley-mitti committed May 7, 2024
1 parent 84b791c commit de345f3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
:host {
--grid-gap: 100px;
}

:host([slot='ruler']) .rux-timeline.rux-track {
Expand Down Expand Up @@ -42,6 +43,14 @@
display: grid;
grid-template-rows: auto;
background: var(--color-background-surface-default);
//gridlines
background-image: repeating-linear-gradient(
to left,
var(--grid-line-color),
var(--grid-line-color) 1px,
transparent 1px,
transparent var(--grid-gap) /* determines gap between lines */
);
}

.rux-track__played {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
h,
Watch,
State,
Fragment,
} from '@stencil/core'
import {
differenceInMinutes,
Expand Down Expand Up @@ -314,31 +313,21 @@ export class RuxTrack {
const hasRuler = [...this.el.children].find(
(el) => el.tagName.toLowerCase() === 'rux-ruler'
)

this.hasRuler = !!hasRuler
}

renderGrid() {
renderCssGrid() {
//we need the width of an hour so we need the interval * whatever the width of a grid col is
const getCols = () => {
if (['minute', 'hour'].includes(this.interval)) return 60
if (['day', 'week', 'month'].includes(this.interval)) return 24
return 60
}
const intervalCols = getCols()
return (
<Fragment>
{[...Array(this.columns)].map((_: any, i: any) =>
i % intervalCols === 0 ? (
<div
style={{
gridColumn: `${i + 2} / ${++i + 2}`,
}}
class="grid-line"
></div>
) : null
)}
</Fragment>
)
const span = getCols()
const width = span * this.width
// we set this as --grid-gap and then use that variable
// in rux-track.scss to set the gap between lines
return `${width}px`
}

render() {
Expand All @@ -348,6 +337,7 @@ export class RuxTrack {
class="rux-timeline rux-track"
style={{
gridTemplateColumns: `[header] 200px repeat(${this.columns}, ${this.width}px)`,
'--grid-gap': this.renderCssGrid(),
}}
part="container"
>
Expand All @@ -370,7 +360,6 @@ export class RuxTrack {
(this.playedIndicator = el as HTMLInputElement)
}
></div>
{this.renderGrid()}
</div>
</Host>
)
Expand Down

0 comments on commit de345f3

Please sign in to comment.