Skip to content

Commit

Permalink
refactor(axis): use css-classes instead of style (#1897)
Browse files Browse the repository at this point in the history
* refactor(axis): use css-classes instead of style

* adds css-classes to ticks to make them more accessible from outside

Signed-off-by: Max Jonas <[email protected]>

* refactor(axis): rename css class

---------

Signed-off-by: Max Jonas <[email protected]>
  • Loading branch information
max-jonas authored Nov 7, 2024
1 parent a4a4f98 commit 344cf09
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 8 additions & 0 deletions packages/core/scss/components/_axis.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
g.tick text {
fill: theme.$text-secondary;
font-family: var(--#{globals.$prefix}-charts-font-family-condensed);

&.tick-label--primary {
font-weight: bold;
}

&.tick-label {
font-weight: normal;
}
}

g.tick line {
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/components/axes/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,11 @@ export class Axis extends Component {
.data(axis.tickValues(), scale)
.order()
.select('text')
ticks.style('font-weight', (tick: number, i: number) => {
return isTickPrimary(tick, i, axis.tickValues(), timeInterval, showDayName)
? 'bold'
: 'normal'
})
ticks.attr('class', (tick: number, i: number) =>
isTickPrimary(tick, i, axis.tickValues(), timeInterval, showDayName)
? 'tick-label--primary'
: 'tick-label'
)
} else {
if (!animate || !axisRefExists) {
axisRef = axisRef.call(axis)
Expand Down

0 comments on commit 344cf09

Please sign in to comment.