Skip to content

Commit

Permalink
Run Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpetri1 committed Sep 7, 2024
1 parent 625f578 commit 472276b
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 167 deletions.
2 changes: 1 addition & 1 deletion packages/tldraw/src/lib/defaultShapeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { HighlightShapeUtil } from './shapes/highlight/HighlightShapeUtil'
import { ImageShapeUtil } from './shapes/image/ImageShapeUtil'
import { LineShapeUtil } from './shapes/line/LineShapeUtil'
import { NoteShapeUtil } from './shapes/note/NoteShapeUtil'
import { PollShapeUtil } from './shapes/poll/PollShapeUtil'
import { TextShapeUtil } from './shapes/text/TextShapeUtil'
import { VideoShapeUtil } from './shapes/video/VideoShapeUtil'
import { PollShapeUtil } from './shapes/poll/PollShapeUtil'

/** @public */
export const defaultShapeUtils: TLAnyShapeUtilConstructor[] = [
Expand Down
8 changes: 4 additions & 4 deletions packages/tldraw/src/lib/shapes/poll/PollShapeTool.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BaseBoxShapeTool } from "@bigbluebutton/editor";
import { BaseBoxShapeTool } from '@bigbluebutton/editor'

export class PollShapeTool extends BaseBoxShapeTool {
static override id = 'poll'
static override initial = 'idle'
override shapeType = 'poll'
static override id = 'poll'
static override initial = 'idle'
override shapeType = 'poll'
}
224 changes: 110 additions & 114 deletions packages/tldraw/src/lib/shapes/poll/PollShapeUtil.tsx
Original file line number Diff line number Diff line change
@@ -1,119 +1,115 @@
import React from 'react';
import {
HTMLContainer,
Rectangle2d,
ShapeUtil,
TLOnResizeHandler,
getDefaultColorTheme,
resizeBox,
HTMLContainer,
Rectangle2d,
ShapeUtil,
TLOnResizeHandler,
getDefaultColorTheme,
resizeBox,
} from '@bigbluebutton/editor'
import React from 'react'

import { pollShapeMigrations } from './poll-shape-migrations';
import { pollShapeProps } from './poll-shape-props';
import { IPollShape } from './poll-shape-types';
import ChatPollContent from './components/poll-content';
import ChatPollContent from './components/poll-content'
import { pollShapeMigrations } from './poll-shape-migrations'
import { pollShapeProps } from './poll-shape-props'
import { IPollShape } from './poll-shape-types'

export class PollShapeUtil extends ShapeUtil<IPollShape> {
static override type = 'poll' as const;

static override props = pollShapeProps;

static override migrations = pollShapeMigrations;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
override isAspectRatioLocked = (_shape: IPollShape) => false;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
override canResize = (_shape: IPollShape) => true;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
override canBind = (_shape: IPollShape) => true;

getDefaultProps(): IPollShape['props'] {
return {
w: 300,
h: 300,
color: 'black',
fill: 'white',
question: '',
numRespondents: 0,
numResponders: 0,
questionText: '',
questionType: '',
answers: [],
};
}

// eslint-disable-next-line class-methods-use-this
getGeometry(shape: IPollShape) {
return new Rectangle2d({
width: shape.props.w,
height: shape.props.h,
isFilled: true,
});
}

component(shape: IPollShape) {
const { bounds } = this.editor.getShapeGeometry(shape);
const theme = getDefaultColorTheme({
isDarkMode: this.editor.user.getIsDarkMode(),
});

const contentRef = React.useRef<HTMLDivElement>(null);
const pollMetadata = JSON.stringify({
id: shape.id,
question: shape.props.question,
numRespondents: shape.props.numRespondents,
numResponders: shape.props.numResponders,
questionText: shape.props.questionText,
questionType: shape.props.questionType,
answers: shape.props.answers,
});

const adjustedHeight = shape.props.questionText.length > 0 ? bounds.height - 75 : bounds.height;

return (
<HTMLContainer
id={shape.id}
style={{
border: '1px solid #8B9AA8',
borderRadius: '4px',
boxShadow: '0px 0px 4px 0px rgba(0, 0, 0, 0.20)',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
pointerEvents: 'all',
backgroundColor: theme[shape.props.color].semi,
color: theme[shape.props.color].solid,
}}
>
<div
ref={contentRef}
style={{
width: `${bounds.width}px`,
overflow: 'hidden',
position: 'relative',
}}
>
<ChatPollContent
metadata={pollMetadata}
height={adjustedHeight}
/>
</div>
</HTMLContainer>
);
}

// eslint-disable-next-line class-methods-use-this
indicator(shape: IPollShape) {
return <rect width={shape.props.w} height={shape.props.h} />;
}

override onResize: TLOnResizeHandler<IPollShape> = (shape, info) => {
return resizeBox(shape, info);
}
}

export default PollShapeUtil;

static override type = 'poll' as const

static override props = pollShapeProps

static override migrations = pollShapeMigrations

// eslint-disable-next-line @typescript-eslint/no-unused-vars
override isAspectRatioLocked = (_shape: IPollShape) => false

// eslint-disable-next-line @typescript-eslint/no-unused-vars
override canResize = (_shape: IPollShape) => true

// eslint-disable-next-line @typescript-eslint/no-unused-vars
override canBind = (_shape: IPollShape) => true

getDefaultProps(): IPollShape['props'] {
return {
w: 300,
h: 300,
color: 'black',
fill: 'white',
question: '',
numRespondents: 0,
numResponders: 0,
questionText: '',
questionType: '',
answers: [],
}
}

// eslint-disable-next-line class-methods-use-this
getGeometry(shape: IPollShape) {
return new Rectangle2d({
width: shape.props.w,
height: shape.props.h,
isFilled: true,
})
}

component(shape: IPollShape) {
const { bounds } = this.editor.getShapeGeometry(shape)
const theme = getDefaultColorTheme({
isDarkMode: this.editor.user.getIsDarkMode(),
})

const contentRef = React.useRef<HTMLDivElement>(null)
const pollMetadata = JSON.stringify({
id: shape.id,
question: shape.props.question,
numRespondents: shape.props.numRespondents,
numResponders: shape.props.numResponders,
questionText: shape.props.questionText,
questionType: shape.props.questionType,
answers: shape.props.answers,
})

const adjustedHeight = shape.props.questionText.length > 0 ? bounds.height - 75 : bounds.height

return (
<HTMLContainer
id={shape.id}
style={{
border: '1px solid #8B9AA8',
borderRadius: '4px',
boxShadow: '0px 0px 4px 0px rgba(0, 0, 0, 0.20)',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
pointerEvents: 'all',
backgroundColor: theme[shape.props.color].semi,
color: theme[shape.props.color].solid,
}}
>
<div
ref={contentRef}
style={{
width: `${bounds.width}px`,
overflow: 'hidden',
position: 'relative',
}}
>
<ChatPollContent metadata={pollMetadata} height={adjustedHeight} />
</div>
</HTMLContainer>
)
}

// eslint-disable-next-line class-methods-use-this
indicator(shape: IPollShape) {
return <rect width={shape.props.w} height={shape.props.h} />
}

override onResize: TLOnResizeHandler<IPollShape> = (shape, info) => {
return resizeBox(shape, info)
}
}

export default PollShapeUtil
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TLUiTranslationKey } from '../../../ui/hooks/useTranslation/TLUiTranslationKey'
import React from 'react'
import { Bar, BarChart, ResponsiveContainer, XAxis, YAxis } from 'recharts'
import { TLUiTranslationKey } from '../../../ui/hooks/useTranslation/TLUiTranslationKey'
import Styled from './styles'

const caseInsensitiveReducer = (acc: any[], item: { key: string; numVotes: number }) => {
Expand Down
28 changes: 14 additions & 14 deletions packages/tldraw/src/lib/shapes/poll/components/styles.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import styled from 'styled-components';
import styled from 'styled-components'

export const PollText = styled.div`
margin-top: 0.5rem;
margin-bottom: 0.5rem;
font-size: 1.25rem;
font-weight: 500;
margin-left: 2.75rem;
color: var(--color-text, var(--color-gray, #4E5A66));
word-break: break-word;
`;
margin-top: 0.5rem;
margin-bottom: 0.5rem;
font-size: 1.25rem;
font-weight: 500;
margin-left: 2.75rem;
color: var(--color-text, var(--color-gray, #4e5a66));
word-break: break-word;
`

export const PollWrapper = styled.div`
width: 100%;
`;
width: 100%;
`

export default {
PollText,
PollWrapper,
};
PollText,
PollWrapper,
}
28 changes: 14 additions & 14 deletions packages/tldraw/src/lib/shapes/poll/poll-shape-props.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { DefaultColorStyle, ShapeProps, T } from '@bigbluebutton/editor';
import { IPollShape } from './poll-shape-types';
import { DefaultColorStyle, ShapeProps, T } from '@bigbluebutton/editor'
import { IPollShape } from './poll-shape-types'

export const pollShapeProps: ShapeProps<IPollShape> = {
w: T.number,
h: T.number,
color: DefaultColorStyle,
fill: T.string,
question: T.string,
numRespondents: T.number,
numResponders: T.number,
questionText: T.string,
questionType: T.string,
answers: T.any,
};
w: T.number,
h: T.number,
color: DefaultColorStyle,
fill: T.string,
question: T.string,
numRespondents: T.number,
numResponders: T.number,
questionText: T.string,
questionType: T.string,
answers: T.any,
}

export default pollShapeProps;
export default pollShapeProps
36 changes: 18 additions & 18 deletions packages/tldraw/src/lib/shapes/poll/poll-shape-types.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { TLBaseShape, TLDefaultColorStyle } from '@bigbluebutton/editor';
import { TLBaseShape, TLDefaultColorStyle } from '@bigbluebutton/editor'

export type IPollShape = TLBaseShape<
'poll',
{
w: number,
h: number,
color: TLDefaultColorStyle,
fill: string,
question: string,
numRespondents: number,
numResponders: number,
questionText: string,
questionType: string,
answers: Array<{
id: number,
key: string,
numVotes: number,
}>,
}
'poll',
{
w: number
h: number
color: TLDefaultColorStyle
fill: string
question: string
numRespondents: number
numResponders: number
questionText: string
questionType: string
answers: Array<{
id: number
key: string
numVotes: number
}>
}
>
3 changes: 2 additions & 1 deletion public-yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@bigbluebutton/monorepo@workspace:."
dependencies:
"@bigbluebutton/tldraw": "workspace:^"
"@microsoft/api-extractor": ^7.35.4
"@next/eslint-plugin-next": ^13.3.0
"@swc/core": ^1.3.55
Expand Down Expand Up @@ -1795,7 +1796,7 @@ __metadata:
languageName: unknown
linkType: soft

"@bigbluebutton/[email protected], @bigbluebutton/tldraw@workspace:packages/tldraw":
"@bigbluebutton/[email protected], @bigbluebutton/tldraw@workspace:^, @bigbluebutton/tldraw@workspace:packages/tldraw":
version: 0.0.0-use.local
resolution: "@bigbluebutton/tldraw@workspace:packages/tldraw"
dependencies:
Expand Down

0 comments on commit 472276b

Please sign in to comment.