Skip to content

Commit

Permalink
Minor type fix for FitText and enhance examples to use sub-components.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-roemer committed Dec 13, 2024
1 parent 9f64d9b commit 412e5b3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const Presentation = () => (
<Slide>
<Heading>This is a Heading</Heading>
<FitText>
This is a <code>FitText</code> component
This is a <CodeSpan>FitText</CodeSpan> component
</FitText>
<FitText
color="secondary"
Expand Down
2 changes: 1 addition & 1 deletion examples/one-page/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
</${Slide}>
<${Slide}>
<${Heading}>This is a Heading</${Heading}>
<${FitText}>This is a <code>FitText</code> component</${FitText}>
<${FitText}>This is a <${CodeSpan}>FitText</${CodeSpan}> component</${FitText}>
<${FitText} color="secondary" style=${{
textTransform: 'uppercase',
fontFamily: 'Comic Sans MS'
Expand Down
2 changes: 1 addition & 1 deletion examples/typescript/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const Presentation = () => (
<Slide>
<Heading>This is a Heading</Heading>
<FitText>
This is a <code>FitText</code> component
This is a <CodeSpan>FitText</CodeSpan> component
</FitText>
<FitText
color="secondary"
Expand Down
13 changes: 11 additions & 2 deletions packages/spectacle/src/components/typography.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ import {
SpaceProps,
BorderProps
} from 'styled-system';
import { FC, PropsWithChildren, RefAttributes, useRef, useState } from 'react';
import {
FC,
PropsWithChildren,
RefAttributes,
useRef,
useState,
HTMLAttributes
} from 'react';
import useResizeObserver from 'use-resize-observer';

const decoration = system({ textDecoration: true });
Expand Down Expand Up @@ -134,7 +141,9 @@ ScalableText.defaultProps = {
scale: 1
};

const FitText: FC<PropsWithChildren<CommonTypographyProps>> = (props) => {
const FitText: FC<
PropsWithChildren<CommonTypographyProps & HTMLAttributes<HTMLDivElement>>
> = (props) => {
const containerRef = useRef<HTMLDivElement>(null);
const textRef = useRef<HTMLDivElement>(null);
const [scale, setScale] = useState(1);
Expand Down

0 comments on commit 412e5b3

Please sign in to comment.