Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 57 additions & 59 deletions src/components/Form/ClaimReviewSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { Select } from "antd";
import React, { useContext, useEffect, useState } from "react";
import styled from "styled-components";
import { useAppSelector } from "../../store/store";
import colors from "../../styles/colors";
import ClassificationText from "../ClassificationText";
import ClassificationModal from "./ClassificationModal";
import { VisualEditorContext } from "../Collaborative/VisualEditorProvider";

const { Option } = Select;
import { MenuItem, Select, FormControl } from "@mui/material";

export const SelectInput = styled(Select)`
background: ${colors.white};
Expand All @@ -16,25 +14,23 @@ export const SelectInput = styled(Select)`
border: none;
height: 40px;
width: 100%;
padding: 10px;

.ant-select-selector {
background: none !important;
border: none !important;
top: 6px;
.ant-select-selection-item {
color: ${colors.blackSecondary};
}
}
.MuiSelect-select {
background: none !important;
color: ${colors.blackSecondary};
padding: 0 !important;
}

.ant-select-selection-placeholder {
color: ${colors.blackSecondary};
}
.MuiOutlinedInput-notchedOutline {
border: none !important;
}

::placeholder {
color: ${colors.blackSecondary};
}

:focus {
:focus .MuiOutlinedInput-notchedOutline {
border: none;
box-shadow: 0px 2px 2px ${colors.shadow};
}
Expand All @@ -43,7 +39,7 @@ export const SelectInput = styled(Select)`
border: none;
}

:hover {
:hover .MuiOutlinedInput-notchedOutline {
border: none;
}
`;
Expand All @@ -57,11 +53,11 @@ const ClaimReviewSelect = ({
}) => {
const { vw } = useAppSelector((state) => state);
const [open, setOpen] = useState(false);
const [value, setValue] = useState(defaultValue);
const [value, setValue] = useState(defaultValue || "");
const { editorConfiguration } = useContext(VisualEditorContext);

const onChangeSelect = (e) => {
setValue(e);
setValue(e.target.value);
};

useEffect(() => {
Expand All @@ -84,47 +80,49 @@ const ClaimReviewSelect = ({

return (
<>
<SelectInput
type={type}
onChange={onChangeSelect}
onClick={handleOnClick}
value={value}
disabled={editorConfiguration?.readonly}
data-cy={"testClassificationText"}
dropdownStyle={vw?.sm && { display: "none" }}
style={style}
>
<Option value="" disabled>
{placeholder}
</Option>
<Option value="not-fact">
<ClassificationText classification="not-fact" />
</Option>
<Option value="trustworthy">
<ClassificationText classification="trustworthy" />
</Option>
<Option value="trustworthy-but">
<ClassificationText classification="trustworthy-but" />
</Option>
<Option value="arguable">
<ClassificationText classification="arguable" />
</Option>
<Option value="misleading">
<ClassificationText classification="misleading" />
</Option>
<Option value="false">
<ClassificationText classification="false" />
</Option>
<Option value="unsustainable">
<ClassificationText classification="unsustainable" />
</Option>
<Option value="exaggerated">
<ClassificationText classification="exaggerated" />
</Option>
<Option value="unverifiable">
<ClassificationText classification="unverifiable" />
</Option>
</SelectInput>
<FormControl fullWidth>
<SelectInput
type={type}
onChange={onChangeSelect}
onClick={handleOnClick}
value={value}
disabled={editorConfiguration?.readonly}
data-cy={"testClassificationText"}
dropdownStyle={vw?.sm && { display: "none" }}
style={style}
>
<MenuItem value="" disabled>
{placeholder}
</MenuItem>
<MenuItem sx={{ fontFamily: "open-sans, sans-serif" }} value="not-fact">
<ClassificationText classification="not-fact" />
</MenuItem>
<MenuItem sx={{ fontFamily: "open-sans, sans-serif" }} value="trustworthy">
<ClassificationText classification="trustworthy" />
</MenuItem>
<MenuItem sx={{ fontFamily: "open-sans, sans-serif" }} value="trustworthy-but">
<ClassificationText classification="trustworthy-but" />
</MenuItem>
<MenuItem sx={{ fontFamily: "open-sans, sans-serif" }} value="arguable">
<ClassificationText classification="arguable" />
</MenuItem>
<MenuItem sx={{ fontFamily: "open-sans, sans-serif" }} value="misleading">
<ClassificationText classification="misleading" />
</MenuItem>
<MenuItem sx={{ fontFamily: "open-sans, sans-serif" }} value="false">
<ClassificationText classification="false" />
</MenuItem>
<MenuItem sx={{ fontFamily: "open-sans, sans-serif" }} value="unsustainable">
<ClassificationText classification="unsustainable" />
</MenuItem>
<MenuItem sx={{ fontFamily: "open-sans, sans-serif" }} value="exaggerated">
<ClassificationText classification="exaggerated" />
</MenuItem>
<MenuItem sx={{ fontFamily: "open-sans, sans-serif" }} value="unverifiable">
<ClassificationText classification="unverifiable" />
</MenuItem>
</SelectInput>
</FormControl>
<ClassificationModal
open={open}
value={value}
Expand Down
93 changes: 71 additions & 22 deletions src/components/Header/SelectLanguage.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,51 @@
import { Select, Switch } from "antd";
import ReactCountryFlag from "react-country-flag";
import Cookies from "js-cookie";
import React, { useLayoutEffect, useState } from "react";
import styled from "styled-components";
import { Select, MenuItem, Switch } from "@mui/material";
import colors from "../../styles/colors";
import { useAppSelector } from "../../store/store";
import { NameSpaceEnum } from "../../types/Namespace";
import { useAtom } from "jotai";
import { currentNameSpace } from "../../atoms/namespace";

const { Option } = Select;

const SelectInput = styled(Select)`
.ant-select-selection-item {
.MuiOutlinedInput-notchedOutline {
border: none;
}

.MuiSelect-select {
display: flex;
align-items: center;
}

.ant-select-arrow {
.MuiSvgIcon-root {
color: ${colors.white};
font-size: 0.8rem;
}
`;

const SwitchInputStyle = styled(Switch)`
const StyledSwitch = styled(Switch)`
.MuiSwitch-switchBase {
padding: 6px;
}

MuiSwitch-thumb {
display: flex;
align-items: center;
justify-content: center;
background-color: ${colors.white};
border-radius: 50%;
}

.MuiSwitch-track {
border-radius: 22px;
background-color: ${({ namespace }) =>
namespace === NameSpaceEnum.Main
? colors.primary
: colors.secondary};
namespace === NameSpaceEnum.Main ? colors.secondary : colors.primary};
opacity: 1;
height: 18px;
}
`;

const SelectLanguage = (props: { defaultLanguage; dataCy }) => {
Expand Down Expand Up @@ -61,21 +79,23 @@ const SelectLanguage = (props: { defaultLanguage; dataCy }) => {
bordered={false}
showArrow={true}
value={language}
onChange={(e) => setDefaultLanguage(e.target.value as string)}
onSelect={setDefaultLanguage}
data-cy={props.dataCy}
loading={switchLoading}
>
<Option value="pt" data-cy="testLanguagePt">
<MenuItem value="pt" data-cy="testLanguagePt">
<ReactCountryFlag
countryCode="BR"
style={{ fontSize: "20px", paddingTop: "6px" }}
style={{ fontSize: "18px", borderRadius: "50%" }}
/>
</Option>
<Option value="en" data-cy="testLanguageEn">
</MenuItem>
<MenuItem value="en" data-cy="testLanguageEn">
<ReactCountryFlag
countryCode="GB"
style={{ fontSize: "20px", paddingTop: "6px" }}
style={{ fontSize: "18px", borderRadius: "50%" }}
/>
</Option>
</MenuItem>
</SelectInput>
)}
{vw?.xs && (
Expand All @@ -90,15 +110,44 @@ const SelectLanguage = (props: { defaultLanguage; dataCy }) => {
<span style={{ fontSize: 10 }}>
{language === "pt" ? "BR" : "EN"}
</span>
<SwitchInputStyle
checkedChildren={<ReactCountryFlag countryCode="BR" />}
unCheckedChildren={
<ReactCountryFlag countryCode="GB" />
}
defaultChecked={language === "pt"}
onChange={onChangeSwitch}
loading={switchLoading}
<StyledSwitch
checked={language === "pt"}
onChange={(e) => onChangeSwitch(e.target.checked)}
namespace={nameSpaceProp}
icon={
<ReactCountryFlag
countryCode="GB"
style={{
fontSize: "16px",
paddingTop: "6px",
borderRadius: "50%",
backgroundColor: colors.white,
width: "24px",
height: "24px",
display: "flex",
alignItems: "center",
justifyContent: "center",
boxShadow: "0 2px 4px rgba(0, 0, 0, 0.2)",
}}
/>
}
checkedIcon={
<ReactCountryFlag
countryCode="BR"
style={{
fontSize: "16px",
paddingTop: "6px",
borderRadius: "50%",
backgroundColor: colors.white,
width: "24px",
height: "24px",
display: "flex",
alignItems: "center",
justifyContent: "center",
boxShadow: "0 2px 4px rgba(0, 0, 0, 0.2)",
}}
/>
}
/>
</div>
)}
Expand Down
Loading