Skip to content

Commit

Permalink
More jsx to tsx migration
Browse files Browse the repository at this point in the history
  • Loading branch information
HarelM committed Dec 21, 2023
1 parent 12def85 commit af8caef
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 45 deletions.
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"@types/react": "^16.14.52",
"@types/react-aria-modal": "^4.0.9",
"@types/react-autocomplete": "^1.8.9",
"@types/react-collapse": "^5.0.4",
"@types/react-color": "^3.0.10",
"@types/react-dom": "^16.9.24",
"@types/react-file-reader-input": "^2.0.4",
Expand Down
14 changes: 7 additions & 7 deletions src/components/Collapse.jsx → src/components/Collapse.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Collapse as ReactCollapse } from 'react-collapse'
import {reducedMotionEnabled} from '../../libs/accessibility'
import {reducedMotionEnabled} from '../libs/accessibility'


export default class Collapse extends React.Component {
static propTypes = {
isActive: PropTypes.bool.isRequired,
children: PropTypes.element.isRequired
}
type CollapseProps = {
isActive: boolean
children: React.ReactElement
};


export default class Collapse extends React.Component<CollapseProps> {
static defaultProps = {
isActive: true
}
Expand Down
11 changes: 5 additions & 6 deletions src/components/Collapser.jsx → src/components/Collapser.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React from 'react'
import PropTypes from 'prop-types'
import {MdArrowDropDown, MdArrowDropUp} from 'react-icons/md'

export default class Collapser extends React.Component {
static propTypes = {
isCollapsed: PropTypes.bool.isRequired,
style: PropTypes.object,
}
type CollapserProps = {
isCollapsed: boolean
style?: object
};

export default class Collapser extends React.Component<CollapserProps> {
render() {
const iconStyle = {
width: 20,
Expand Down
20 changes: 0 additions & 20 deletions src/components/FieldAutocomplete.jsx

This file was deleted.

20 changes: 20 additions & 0 deletions src/components/FieldAutocomplete.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react'
import Block from './Block'
import InputAutocomplete, { InputAutocompleteProps } from './InputAutocomplete'


type FieldAutocompleteProps = InputAutocompleteProps & {
label?: string;
};


export default class FieldAutocomplete extends React.Component<FieldAutocompleteProps> {
render() {
const {props} = this;

return <Block label={props.label}>
<InputAutocomplete {...props} />
</Block>
}
}

Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import React from 'react'
import PropTypes from 'prop-types'

import Block from './Block'
import InputString from './InputString'

export default class FieldComment extends React.Component {
static propTypes = {
value: PropTypes.string,
onChange: PropTypes.func.isRequired,
}
type FieldCommentProps = {
value?: string
onChange(...args: unknown[]): unknown
};

export default class FieldComment extends React.Component<FieldCommentProps> {
render() {
const fieldSpec = {
doc: "Comments for the current layer. This is non-standard and not in the spec."
Expand Down
12 changes: 6 additions & 6 deletions src/libs/accessibility.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import throttle from 'lodash.throttle'

export default {
// Throttle for 3 seconds so when a user enables it they don't have to refresh the page.
reducedMotionEnabled: throttle(() => {
return window.matchMedia("(prefers-reduced-motion: reduce)").matches
}, 3000)
}
// Throttle for 3 seconds so when a user enables it they don't have to refresh the page.
const reducedMotionEnabled = throttle(() => {
return window.matchMedia("(prefers-reduced-motion: reduce)").matches
}, 3000)

export { reducedMotionEnabled }

0 comments on commit af8caef

Please sign in to comment.