Skip to content

Commit

Permalink
Progress point
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed May 15, 2024
1 parent 97960ec commit c12c593
Show file tree
Hide file tree
Showing 4 changed files with 280 additions and 39 deletions.
1 change: 1 addition & 0 deletions src/hooks/use-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const LayoutContext = createContext<Layout>({
width: 0,
height: 0,
});
LayoutContext.displayName = 'LayoutContext';

export function useLayout() {
return useContext(LayoutContext);
Expand Down
1 change: 1 addition & 0 deletions src/hooks/use-parent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createContext, useContext } from 'react';
import type { Root } from '../root.js';

export const ParentContext = createContext<Root | null>(null);
ParentContext.displayName = 'ParentContext';

export function useParent() {
const parent = useContext(ParentContext);
Expand Down
15 changes: 14 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export {
};
export type { _Canvas as CanvasRef };

export const Arc = factory<_Arc, ArcProps>('Arc');
export const Canvas = factory<_Canvas, CanvasProps>('Canvas');
export const Image = factory<_Image, ImageProps>('Image');
export const Path = factory<_Path, PathProps>('Path');
Expand All @@ -63,6 +62,20 @@ export type TextProps = Omit<_TextProps, 'value'> & {
};
export const Text = factory<_Text, TextProps>('Text');

//export const Arc = factory<_Arc, ArcProps>('Arc');
export const Arc = forwardRef<_Arc, ArcProps>((props, ref) => {
const layout = useAdjustedLayout(props);
const radius = props.radius ?? Math.min(layout.width, layout.height) / 2;
return createElement('Arc', {
...props,
x: layout.x,
y: layout.y,
radius,
ref,
});
});
Arc.displayName = 'Arc';

export type CircleProps = Omit<
ArcProps,
'startAngle' | 'endAngle' | 'counterclockwise'
Expand Down
Loading

0 comments on commit c12c593

Please sign in to comment.