Skip to content

Commit

Permalink
refactor(axes): rename AxisProp to SingleAxisProp
Browse files Browse the repository at this point in the history
  • Loading branch information
wyze committed Apr 30, 2021
1 parent b5d5f0f commit 93943b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions packages/axes/src/components/Axes.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { Axis } from './Axis'
import { positions } from '../props'
import { AnyScale, AxisProp, AxisValue } from '../types'
import { AnyScale, SingleAxisProp, AxisValue } from '../types'

export const Axes = <X extends AxisValue, Y extends AxisValue>({
xScale,
Expand All @@ -17,19 +17,19 @@ export const Axes = <X extends AxisValue, Y extends AxisValue>({
yScale: AnyScale
width: number
height: number
top?: AxisProp<X>
right?: AxisProp<Y>
bottom?: AxisProp<X>
left?: AxisProp<Y>
top?: SingleAxisProp<X>
right?: SingleAxisProp<Y>
bottom?: SingleAxisProp<X>
left?: SingleAxisProp<Y>
}) => {
const axes = { top, right, bottom, left }

return (
<>
{positions.map(position => {
const axis = axes[position] as typeof position extends 'bottom' | 'top'
? AxisProp<X> | undefined
: AxisProp<Y> | undefined
? SingleAxisProp<X> | undefined
: SingleAxisProp<Y> | undefined

if (!axis) return null

Expand Down
4 changes: 2 additions & 2 deletions packages/axes/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export type AxisLegendPosition = 'start' | 'middle' | 'end'

export type ValueFormatter<Value extends AxisValue> = (value: Value) => Value | string

export interface AxisProp<Value extends AxisValue> {
export interface SingleAxisProp<Value extends AxisValue> {
ticksPosition?: 'before' | 'after'
tickValues?: TicksSpec<Value>
tickSize?: number
Expand All @@ -69,7 +69,7 @@ export interface AxisProp<Value extends AxisValue> {
}

export interface CanvasAxisProp<Value extends string | number | Date>
extends Omit<AxisProp<Value>, 'legend'> {
extends Omit<SingleAxisProp<Value>, 'legend'> {
legend?: string
}

Expand Down

0 comments on commit 93943b8

Please sign in to comment.