Skip to content

Commit

Permalink
Merge pull request #22 from indexnetwork/new-flow
Browse files Browse the repository at this point in the history
New flow
  • Loading branch information
serefyarar authored Feb 6, 2024
2 parents 3d4f42a + 08fb3b2 commit d56523d
Show file tree
Hide file tree
Showing 57 changed files with 436 additions and 678 deletions.
16 changes: 12 additions & 4 deletions web-app/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"rules": {
"no-console": "off",
"implicit-arrow-linebreak": ["beside"],
"implicit-arrow-linebreak": "off",
"linebreak-style": "off",
"no-plusplus": "off",
"no-unused-vars": "off",
Expand All @@ -41,7 +41,13 @@
"argsIgnorePattern": "^_"
}
],
"quotes": ["error", "double", { "allowTemplateLiterals": true }],
"quotes": [
"error",
"double",
{
"allowTemplateLiterals": true
}
],
"no-tabs": "off",
"max-classes-per-file": "off",
"radix": 0,
Expand All @@ -56,7 +62,6 @@
],
"consistent-return": "warn",
"no-restricted-properties": "off",
"operator-linebreak": ["error", "after"],
"no-use-before-define": "off",
"no-mixed-spaces-and-tabs": "off",
"no-param-reassign": "off",
Expand All @@ -70,7 +75,10 @@
// Typescript Rules
"@typescript-eslint/no-unused-vars": [
"off",
{ "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }
{
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_"
}
],
"@typescript-eslint/quotes": "off",
"@typescript-eslint/return-await": "off",
Expand Down
11 changes: 6 additions & 5 deletions web-app/src/components/ai/chat-message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import remarkBreaks from "remark-breaks";
import remarkGfm from "remark-gfm";
import remarkMath from "remark-math";

import { useApp } from "@/context/AppContext";
import { ChatMessageActions } from "components/ai/chat-message-actions";
import { MemoizedReactMarkdown } from "components/ai/markdown";
import { CodeBlock } from "components/ai/ui/codeblock";
Expand All @@ -13,8 +14,6 @@ import Input from "components/base/Input";
import Col from "components/layout/base/Grid/Col";
import Flex from "components/layout/base/Grid/Flex";
import FlexRow from "components/layout/base/Grid/FlexRow";
import { useAppSelector } from "hooks/store";
import { selectProfile } from "store/slices/profileSlice";

export interface ChatMessageProps {
message: Message;
Expand All @@ -37,13 +36,13 @@ export function ChatMessage({
index,
editingIndex,
}: ChatMessageProps) {
const profile = useAppSelector(selectProfile);
const { viewedProfile } = useApp();

return (
<FlexRow wrap={false} align={"start"} className="chat-message py-5">
<Col>
{message.role === "user" ? (
<Avatar size={24} user={profile} />
<Avatar size={24} user={viewedProfile} />
) : (
<div
style={{
Expand Down Expand Up @@ -97,7 +96,9 @@ export function ChatMessage({
</p>
);
},
code({ inline, className, children, ...props }) {
code({
inline, className, children, ...props
}) {
if (children.length) {
if (children[0] === "▍") {
return (
Expand Down
4 changes: 2 additions & 2 deletions web-app/src/components/ai/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import ReactMarkdown, { Options } from "react-markdown";

export const MemoizedReactMarkdown: FC<Options> = memo(
ReactMarkdown,
(prevProps, nextProps) => prevProps.children === nextProps.children &&
prevProps.className === nextProps.className,
(prevProps, nextProps) => prevProps.children === nextProps.children
&& prevProps.className === nextProps.className,
);
153 changes: 81 additions & 72 deletions web-app/src/components/base/Avatar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,83 +4,92 @@ import { generateRandomColor, isSSR } from "utils/helper";
import { ShapeType } from "types";
import { Users } from "types/entity";
import { appConfig } from "config";
import { ProfileState } from "store/slices/profileSlice";

export interface AvatarProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
size?: number;
user?: Users | ProfileState;
creatorRule?: any;
shape?: ShapeType;
hoverable?: boolean;
contentRatio?: number;
randomColor?: boolean;
bgColor?: string;
export interface AvatarProps
extends React.DetailedHTMLProps<
React.HTMLAttributes<HTMLDivElement>,
HTMLDivElement
> {
size?: number;
user?: Users;
creatorRule?: any;
shape?: ShapeType;
hoverable?: boolean;
contentRatio?: number;
randomColor?: boolean;
bgColor?: string;
}

const Avatar = (
{
size = 40,
user,
creatorRule,
children,
className,
style,
bgColor,
shape = "circle",
hoverable = false,
randomColor = false,
...divProps
}: AvatarProps,
) => {
const maxLetters = size > 32 ? 4 : 2;
const [color, setColor] = useState<string>(bgColor || "var(--main)");
const getFontSize = () => size * (1 / maxLetters);
useEffect(() => {
if (!isSSR() && randomColor) {
setColor(generateRandomColor());
}
}, []);
const Avatar = ({
size = 40,
user,
creatorRule,
children,
className,
style,
bgColor,
shape = "circle",
hoverable = false,
randomColor = false,
...divProps
}: AvatarProps) => {
const maxLetters = size > 32 ? 4 : 2;
const [color, setColor] = useState<string>(bgColor || "var(--main)");
const getFontSize = () => size * (1 / maxLetters);
useEffect(() => {
if (!isSSR() && randomColor) {
setColor(generateRandomColor());
}
}, []);

return (
<div
{...divProps}
className={cc(
[
"avatar",
`avatar-${shape}`,
hoverable ? "avatar-hoverable" : "",
className || "",
],
)}
style={{
...style,
width: size,
height: size,
lineHeight: `${size}px`,
fontSize: getFontSize(),
return (
<div
{...divProps}
className={cc([
"avatar",
`avatar-${shape}`,
hoverable ? "avatar-hoverable" : "",
className || "",
])}
style={{
...style,
width: size,
height: size,
lineHeight: `${size}px`,
fontSize: getFontSize(),

backgroundColor: color,
}}
>
{
user ? (
user.avatar ? (
<img src={`${appConfig.ipfsProxy}/${user.avatar}`} alt="profile_img"/>
) : (
user.name ? user.name!.substring(0, 1).toUpperCase() : (user.id ? user.id.toString().slice(maxLetters * -1).toUpperCase() : "Y")
)
) : creatorRule ? (
creatorRule.image ? (
<img src={creatorRule.image} alt="profile_img"/>
) : (
(creatorRule.symbol || creatorRule.ensName)?.substring(0, 4).toUpperCase()
)
) : (
typeof children !== "string" ? children : null
)
}
</div>
);
backgroundColor: color,
}}
>
{user ? (
user.avatar ? (
<img
src={`${appConfig.ipfsProxy}/${user.avatar}`}
alt="profile_img"
/>
) : user.name ? (
user.name!.substring(0, 1).toUpperCase()
) : user.id ? (
user.id
.toString()
.slice(maxLetters * -1)
.toUpperCase()
) : (
"Y"
)
) : creatorRule ? (
creatorRule.image ? (
<img src={creatorRule.image} alt="profile_img" />
) : (
(creatorRule.symbol || creatorRule.ensName)
?.substring(0, 4)
.toUpperCase()
)
) : typeof children !== "string" ? (
children
) : null}
</div>
);
};

export default Avatar;
8 changes: 4 additions & 4 deletions web-app/src/components/base/BottomMenuDiv/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ const BottomMenuDiv = (
const handleMouseUp = useCallback((e: any) => {
if (typeof e !== "boolean" && e) {
setState((currentState) => {
const collapsed = currentState.maxHeight! <
currentState.originalHeight! * collapseThresholdForMinSize;
const collapsed = currentState.maxHeight!
< currentState.originalHeight! * collapseThresholdForMinSize;
return {
maxHeight: collapsed ? 0 : currentState.originalHeight!,
transition,
Expand Down Expand Up @@ -224,8 +224,8 @@ const BottomMenuDiv = (
className="modal-mobile-swiper-button"></div>
</div>
{children}
</DynamicDiv> :
<div
</DynamicDiv>
: <div
{...divProps}
>
{children}
Expand Down
4 changes: 2 additions & 2 deletions web-app/src/components/base/ButtonGroup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const ButtonGroup = (
className || "",
])
}>{
children &&
React.Children.map(children, (child: React.ReactElement<any>) => <div className="btn-group-item">{
children
&& React.Children.map(children, (child: React.ReactElement<any>) => <div className="btn-group-item">{
child
}
</div>)
Expand Down
4 changes: 2 additions & 2 deletions web-app/src/components/base/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const List: FC<ListProps> = ({

return (
<ul className={cc(["list", listClass || ""])}>
{data &&
data.map((item, index) => (
{data
&& data.map((item, index) => (
<ListItem
key={`listItem${index}-${containerId}`}
className={cc([itemContainerClass || ""])}
Expand Down
6 changes: 3 additions & 3 deletions web-app/src/components/base/Popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ const Popup: React.ForwardRefRenderFunction<
const handleClick = (e: any) => {
cancelHover.current = true;
if (
!closeOnMenuClick &&
menuRef.current &&
menuRef.current.contains(e.target)
!closeOnMenuClick
&& menuRef.current
&& menuRef.current.contains(e.target)
) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions web-app/src/components/base/SearchInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ const SearchInput = (
{...inputProps}
inputSize={"lg"}
addOnBefore={<IconSearch width={20} height={20} />}
addOnAfter={loading ? (<Spin active={true} thickness="light" theme="secondary" />) :
(!disabled && showClear && query && <IconClose onClick={handleClear} style={{ cursor: "pointer" }} />)
addOnAfter={loading ? (<Spin active={true} thickness="light" theme="secondary" />)
: (!disabled && showClear && query && <IconClose onClick={handleClear} style={{ cursor: "pointer" }} />)
}
onChange={handleChange}
value={query}
Expand Down
4 changes: 2 additions & 2 deletions web-app/src/components/base/Tag/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ const Tag = (
onKeyDown={handleEnter}
onBlur={handleClose}
/> : value}
{removable && !editActive &&
<div
{removable && !editActive
&& <div
className="tag-remove"
onClick={removable ? handleRemove : undefined}
>
Expand Down
4 changes: 2 additions & 2 deletions web-app/src/components/base/Tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ const Tooltip = (
>
{children}
{
visible &&
<div className={cc(["tooltip-tip", `tooltip-${position}`, wrapperClass || ""])}>
visible
&& <div className={cc(["tooltip-tip", `tooltip-${position}`, wrapperClass || ""])}>
{content}
</div>
}
Expand Down
13 changes: 8 additions & 5 deletions web-app/src/components/layout/base/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,18 @@ const Navbar = ({
return (
<>
{isLanding && (
<Flex
alignitems={"center"}
// alignitems={"space-around"}
style={{ background: "var(--landing)" }}
<div
style={{
backgroundColor: "#f8f8f8",
textAlign: "center",
width: "100%",
padding: "1em",
}}
>
<Text className={"p-5"} size={"md"}>
Index Network is live on testnet.
</Text>
</Flex>
</div>
)}
<div
className={cc([
Expand Down
Loading

0 comments on commit d56523d

Please sign in to comment.