Skip to content

Commit

Permalink
Format exponent to use superscript
Browse files Browse the repository at this point in the history
  • Loading branch information
afterdusk committed May 5, 2021
1 parent 4f19707 commit 6a38878
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Binary file modified preview.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion src/converter/BitPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const Wrapper = styled.div`
overflow-x: auto;
`;

const Superscript = styled.sup`
line-height: 0;
vertical-align: super;
`;

interface BitPanelProps {
name: string;
sign: boolean[];
Expand All @@ -27,6 +32,12 @@ interface BitPanelProps {
}

const BitPanel: FC<BitPanelProps> = (props: BitPanelProps): ReactElement => {
const formattedExponentValue = (
<>
2<Superscript>{props.exponentValue}</Superscript>
</>
);

return (
<Wrapper>
<BitSegment
Expand All @@ -40,7 +51,7 @@ const BitPanel: FC<BitPanelProps> = (props: BitPanelProps): ReactElement => {
/>
<BitSegment
name="Exponent"
value={"2^" + props.exponentValue}
value={formattedExponentValue}
decimal={parseInt(stringifyBits(props.exponent), 2).toFixed()}
bits={props.exponent}
updateBits={(bits: boolean[]) =>
Expand Down
2 changes: 1 addition & 1 deletion src/converter/BitSegment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const BitCheckbox = styled.input``;

interface SegmentProps {
name: string;
value: string;
value: string | ReactElement;
decimal: string;
bits: boolean[];
updateBits: (bits: boolean[]) => void;
Expand Down

0 comments on commit 6a38878

Please sign in to comment.