Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

feat: add password validation #86

Merged
merged 23 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from 19 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
88 changes: 50 additions & 38 deletions src/components/atoms/TextBox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect, useState, useCallback, useRef } from "react";

import Flex from "@reearth/components/atoms/Flex";
import Text from "@reearth/components/atoms/Text";
import { styled, metrics } from "@reearth/theme";
import fonts from "@reearth/theme/fonts";
import { metricsSizes } from "@reearth/theme/metrics";
Expand All @@ -15,6 +16,7 @@ export type Props = {
prefix?: string;
suffix?: string;
placeholder?: string;
message?: string;
KaWaite marked this conversation as resolved.
Show resolved Hide resolved
throttle?: boolean;
throttleTimeout?: number;
color?: string;
Expand All @@ -34,6 +36,7 @@ const TextBox: React.FC<Props> = ({
prefix,
suffix,
placeholder,
message,
throttle,
throttleTimeout: throttleTimeout = 3000,
color,
Expand Down Expand Up @@ -103,44 +106,47 @@ const TextBox: React.FC<Props> = ({
}, [innerValue, onChange, throttle, throttleTimeout]);

return (
<FormWrapper className={className} align="center">
{prefix && (
<FloatedText floatedTextColor={floatedTextColor} color={color}>
{prefix}
</FloatedText>
)}
{multiline ? (
<StyledTextarea
ref={textAreaRef}
value={innerValue ?? ""}
onChange={handleChangeTextArea}
onBlur={handleBlur}
color={color}
backgroundColor={backgroundColor}
disabled={disabled}
placeholder={placeholder}
rows={rows}
/>
) : (
<StyledInput
value={innerValue ?? ""}
onChange={handleChange}
onKeyPress={handleKeyPress}
onBlur={handleBlur}
color={color}
type={type}
backgroundColor={backgroundColor}
disabled={disabled}
placeholder={placeholder}
borderColor={borderColor}
/>
)}
{suffix && (
<FloatedText floatedTextColor={floatedTextColor} color={color}>
{suffix}
</FloatedText>
)}
</FormWrapper>
<div className={className}>
<FormWrapper align="center">
{prefix && (
<FloatedText floatedTextColor={floatedTextColor} color={color}>
{prefix}
</FloatedText>
)}
{multiline ? (
<StyledTextarea
ref={textAreaRef}
value={innerValue ?? ""}
onChange={handleChangeTextArea}
onBlur={handleBlur}
color={color}
backgroundColor={backgroundColor}
disabled={disabled}
placeholder={placeholder}
rows={rows}
/>
) : (
<StyledInput
value={innerValue ?? ""}
onChange={handleChange}
onKeyPress={handleKeyPress}
onBlur={handleBlur}
color={color}
type={type}
backgroundColor={backgroundColor}
disabled={disabled}
placeholder={placeholder}
borderColor={borderColor}
/>
)}
{suffix && (
<FloatedText floatedTextColor={floatedTextColor} color={color}>
{suffix}
</FloatedText>
)}
</FormWrapper>
{message && <StyledText size="xs">{message}</StyledText>}
</div>
);
};

Expand Down Expand Up @@ -194,4 +200,10 @@ const FloatedText = styled.span<InputProps>`
user-select: none;
`;

const StyledText = styled(Text)`
margin-left: ${metricsSizes.m}px;
margin-top: ${metricsSizes["2xs"]}px;
font-style: italic;
`;

export default TextBox;
15 changes: 1 addition & 14 deletions src/components/molecules/Common/ProjectMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ const ProjectMenu: React.FC<Props> = ({ currentProject, teamId }) => {
text={intl.formatMessage({ defaultMessage: "Datasets" })}
/>
</MenuListItem>
{/* <MenuListItem>
<MenuListItemLabel
linkTo={`/settings/project/${currentProject.id}/plugins`}
text={intl.formatMessage({ defaultMessage: "Plugins" })}
/>
</MenuListItem> */}
<Spacer />
<MenuListItem>
<MenuListItemLabel
Expand All @@ -60,17 +54,10 @@ const ProjectMenu: React.FC<Props> = ({ currentProject, teamId }) => {
/>
</MenuListItem>
<Spacer />
<MenuListItem>
<MenuListItemLabel
icon="dashboard"
linkTo={`/dashboard/${teamId}`}
text={intl.formatMessage({ defaultMessage: "Top page" })}
/>
</MenuListItem>
<MenuListItem>
<MenuListItemLabel
icon="help"
linkTo="/projects"
onClick={() => window.open("http://docs.reearth.io")}
KaWaite marked this conversation as resolved.
Show resolved Hide resolved
text={intl.formatMessage({ defaultMessage: "Help" })}
/>
</MenuListItem>
Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/Dashboard/QuickStart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const QuickStart: React.FC<Props> = ({
<LongBannerButton
align="center"
justify="center"
onClick={() => window.location.assign("http://docs.reearth.io")}>
onClick={() => window.open("http://docs.reearth.io")}>
<MapIcon icon="map" />
<Text size="m" weight="bold" customColor>
{intl.formatMessage({ defaultMessage: "User guide" })}
Expand Down
1 change: 1 addition & 0 deletions src/components/molecules/Dashboard/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const StyledLink = styled(Link)`
padding: ${metricsSizes["2xs"]}px;
border-radius: ${metricsSizes.xs}px;
align-self: flex-end;
display: flex;

&:hover {
text-decoration: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { useIntl } from "react-intl";
import Flex from "@reearth/components/atoms/Flex";
import Icon from "@reearth/components/atoms/Icon";
import Text from "@reearth/components/atoms/Text";
import PasswordModal from "@reearth/components/molecules/Settings/Account/PasswordModal";
import PasswordModal, {
PasswordPolicy,
} from "@reearth/components/molecules/Settings/Account/PasswordModal";
import Field from "@reearth/components/molecules/Settings/Field";
import EditableItem from "@reearth/components/molecules/Settings/Project/EditableItem";
import Section from "@reearth/components/molecules/Settings/Section";
Expand All @@ -17,6 +19,7 @@ export type Props = {
appTheme?: string;
lang?: string;
hasPassword: boolean;
passwordPolicy?: PasswordPolicy;
updatePassword?: (password: string, passwordConfirmation: string) => void;
updateLanguage?: (lang: string) => void;
updateTheme?: (theme: string) => void;
Expand All @@ -31,6 +34,7 @@ const ProfileSection: React.FC<Props> = ({
email,
appTheme,
hasPassword,
passwordPolicy,
updatePassword,
updateLanguage,
updateTheme,
Expand Down Expand Up @@ -103,6 +107,7 @@ const ProfileSection: React.FC<Props> = ({
</Section>
<PasswordModal
hasPassword={hasPassword}
passwordPolicy={passwordPolicy}
updatePassword={handleUpdatePassword}
isVisible={isOpen}
onClose={() => setIsOpen(false)}
Expand Down
Loading