Skip to content

Commit

Permalink
Temp feedback box fix
Browse files Browse the repository at this point in the history
  • Loading branch information
majakomel committed Sep 19, 2023
1 parent 7f4e529 commit 20ada30
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
31 changes: 31 additions & 0 deletions components/Radio.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Children, cloneElement, isValidElement } from 'react'
import { Flex } from 'ooni-components'

export const RadioGroup = ({
children,
name,
value,
onChange,
direction = 'column',
...props
}) => {
const iterateOverChildren = (children) => {
return Children.map(children, (child) => {
if (!isValidElement(child)) return null

return cloneElement(child, {
...child.props,
checked: child.props.value === value,
onChange: (e) =>
onChange && onChange(e.target.value),
children: iterateOverChildren(child.props.children),
})
})
}

return (
<Flex flexDirection={direction} {...props}>
{iterateOverChildren(children)}
</Flex>
)
}
3 changes: 2 additions & 1 deletion components/measurement/FeedbackBox.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React, { useEffect, useMemo, useRef, useState } from 'react'
import { Controller, useForm } from 'react-hook-form'
import { FormattedMessage, useIntl } from 'react-intl'
import { Box, Button, Flex, Link, Text, theme, RadioGroup, RadioButton } from 'ooni-components'
import { Box, Button, Flex, Text, theme, RadioButton } from 'ooni-components'
import { GrClose } from 'react-icons/gr'
import useStateMachine from '@cassiozen/usestatemachine'
import SpinLoader from 'components/vendor/SpinLoader'
import { submitFeedback, getAPI } from 'lib/api'
import LoginForm from 'components/login/LoginForm'
import styled from 'styled-components'
import { RadioGroup } from 'components/Radio'

const StyledCloseIcon = styled(GrClose)`
position: absolute;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"markdown-to-jsx": "^7.1.9",
"next": "^12.3.1",
"nprogress": "^0.2.0",
"ooni-components": "1.0.0-alpha.13",
"ooni-components": "1.0.0-alpha.14",
"pretty-ms": "^8.0.0",
"prop-types": "15.8.1",
"react": "17.0.2",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5809,10 +5809,10 @@ onetime@^5.1.0, onetime@^5.1.2:
dependencies:
mimic-fn "^2.1.0"

[email protected].13:
version "1.0.0-alpha.13"
resolved "https://registry.yarnpkg.com/ooni-components/-/ooni-components-1.0.0-alpha.13.tgz#2699412989707432d534cf1ae45788f624474686"
integrity sha512-g2jzDfj8YdZn7OFY10E9kac9ycid8DZEWQ3tPHWDHhreRbsO2/6zUa4kEz9HBHFuix5xggR7jHepvZo+fVYJEQ==
[email protected].14:
version "1.0.0-alpha.14"
resolved "https://registry.yarnpkg.com/ooni-components/-/ooni-components-1.0.0-alpha.14.tgz#d6d26944b56bf6e0be81102d7cd27a44dbc57a25"
integrity sha512-n90KEtXTKT11mA4+F3rnbwZcuZgrUJdrV38CRXgJhD6QTEU9/ADkNDO0ae0sFiR0XZkhbaBBU4hjao/TZgZIFw==
dependencies:
"@styled-system/css" "^5.1.5"
"@styled-system/should-forward-prop" "^5.1.5"
Expand Down

0 comments on commit 20ada30

Please sign in to comment.