From f3201cfd97bd584f35854fc92b08ea3441e73e49 Mon Sep 17 00:00:00 2001
From: Kurt Hutten
Date: Sat, 18 Sep 2021 16:47:17 +1000
Subject: [PATCH] format
---
.../src/components/Hero/AssetWithGooey.tsx | 8 +-
.../components/IdeSideBar/sidebarConfig.tsx | 24 ++-
app/web/src/components/KeyValue/KeyValue.tsx | 37 ++--
.../components/ProjectCard/ProjectCard.tsx | 5 +-
.../ProjectProfile/ProjectProfile.tsx | 188 +++++++++---------
.../components/UserProfile/UserProfile.tsx | 27 ++-
.../UserProfile/userProfileConfig.tsx | 58 +++---
7 files changed, 183 insertions(+), 164 deletions(-)
diff --git a/app/web/src/components/Hero/AssetWithGooey.tsx b/app/web/src/components/Hero/AssetWithGooey.tsx
index dc8f83f..3f9b084 100644
--- a/app/web/src/components/Hero/AssetWithGooey.tsx
+++ b/app/web/src/components/Hero/AssetWithGooey.tsx
@@ -76,8 +76,8 @@ function Gooey() {
const z = randomSign(Math.random() * 2)
const position: [number, number, number] = [x, z, y]
const size = Math.random() * 0.8 + 0.1
- const distort = (size > .1) ? Math.random() * .6 * size + 0.2 : 0
- const speed = (size > .1) ? (Math.random() * 0.8) / size / size + 0.1 : 0
+ const distort = size > 0.1 ? Math.random() * 0.6 * size + 0.2 : 0
+ const speed = size > 0.1 ? (Math.random() * 0.8) / size / size + 0.1 : 0
return { position, size, distort, speed }
})
const secondSet = Array.from({ length: 5 }).map((_, index) => {
@@ -87,8 +87,8 @@ function Gooey() {
const z = randomSign(Math.random() * 2)
const position: [number, number, number] = [x, z, y]
const size = Math.random() * 0.2 + 0.05
- const distort = (size > .1) ? Math.random() * .8 * size + 0.2 : 0
- const speed = (size > .1) ? (Math.random() * 0.5) / size / size + 0.1 : 0
+ const distort = size > 0.1 ? Math.random() * 0.8 * size + 0.2 : 0
+ const speed = size > 0.1 ? (Math.random() * 0.5) / size / size + 0.1 : 0
return { position, size, distort, speed }
})
return [...firstSet, ...secondSet]
diff --git a/app/web/src/components/IdeSideBar/sidebarConfig.tsx b/app/web/src/components/IdeSideBar/sidebarConfig.tsx
index 1ac449b..7b0e3fd 100644
--- a/app/web/src/components/IdeSideBar/sidebarConfig.tsx
+++ b/app/web/src/components/IdeSideBar/sidebarConfig.tsx
@@ -53,13 +53,14 @@ export const sidebarTopConfig: SidebarConfigType[] = [
]
const DiscordLink = () => (
-
- Discord
-
+
+ Discord
+
)
const settingsConfig = [
@@ -74,7 +75,8 @@ const settingsConfig = [
- We're building configuration settings for the Viewer pane now. Join us on if you want to lend a hand!
+ We're building configuration settings for the Viewer pane now. Join us
+ on if you want to lend a hand!
),
@@ -90,7 +92,8 @@ const settingsConfig = [
- We're building configuration settings for the Viewer pane now. Join us on if you want to lend a hand!
+ We're building configuration settings for the Viewer pane now. Join us
+ on if you want to lend a hand!
),
@@ -106,7 +109,8 @@ const settingsConfig = [
- We're building configuration settings for the Viewer pane now. Join us on if you want to lend a hand!
+ We're building configuration settings for the Viewer pane now. Join us
+ on if you want to lend a hand!
),
diff --git a/app/web/src/components/KeyValue/KeyValue.tsx b/app/web/src/components/KeyValue/KeyValue.tsx
index 5d93378..1f75127 100644
--- a/app/web/src/components/KeyValue/KeyValue.tsx
+++ b/app/web/src/components/KeyValue/KeyValue.tsx
@@ -7,24 +7,25 @@ interface EditToggleType {
}
const EditToggle = ({
- onEdit = () => { console.error('Field declared editable without edit action.') },
+ onEdit = () => {
+ console.error('Field declared editable without edit action.')
+ },
isEditing = false,
-} : EditToggleType) => (
- (isEditing ? (
-
-
- Update
-
- ) : (
-
-
-
- ))
-)
+}: EditToggleType) =>
+ isEditing ? (
+
+
+ Update
+
+ ) : (
+
+
+
+ )
interface KeyValueType {
keyName: string
@@ -51,7 +52,7 @@ const KeyValue = ({
}
>
{keyName}
- {edit && edit.hasPermissionToEdit && }
+ {edit && edit.hasPermissionToEdit && }
{children}
diff --git a/app/web/src/components/ProjectCard/ProjectCard.tsx b/app/web/src/components/ProjectCard/ProjectCard.tsx
index fa0f303..6652690 100644
--- a/app/web/src/components/ProjectCard/ProjectCard.tsx
+++ b/app/web/src/components/ProjectCard/ProjectCard.tsx
@@ -32,10 +32,7 @@ const ProjectCard = ({ title, mainImage, user, Reaction, cadPackage }) => (
-
+
{title}
diff --git a/app/web/src/components/ProjectProfile/ProjectProfile.tsx b/app/web/src/components/ProjectProfile/ProjectProfile.tsx
index 399021c..90e454b 100644
--- a/app/web/src/components/ProjectProfile/ProjectProfile.tsx
+++ b/app/web/src/components/ProjectProfile/ProjectProfile.tsx
@@ -102,41 +102,43 @@ const ProjectProfile = ({
className="px-3 py-2 rounded"
/>
- { (project?.description || hasPermissionToEdit) &&
{
- if (!isEditing) {
- setIsEditing(true)
- } else {
- onEditSaveClick()
- setIsEditing(false)
- }
- },
- }}
- >
-
- e?.target?.id === 'description-wrap' &&
- editorRef?.current?.focusAtEnd()
- }
+ {(project?.description || hasPermissionToEdit) && (
+ {
+ if (!isEditing) {
+ setIsEditing(true)
+ } else {
+ onEditSaveClick()
+ setIsEditing(false)
+ }
+ },
+ }}
>
-
-
- }
+
+ e?.target?.id === 'description-wrap' &&
+ editorRef?.current?.focusAtEnd()
+ }
+ >
+
+
+
+ )}
{new Date(project?.createdAt).toDateString()}
@@ -154,64 +156,68 @@ const ProjectProfile = ({
className=""
/>
- { currentUser &&
- {!isEditing && (
- <>
- {currentUser && (
- <>
-
-
-
- Comment
-
- >
- )}
-
- >
- )}
- }
+
+ {project?.Comment.map(
+ ({ text, user, id, createdAt }) => (
+
+
+
+
+ {user?.userName}
+
+
+ {new Date(createdAt).toDateString()}
+
+
+
+ {text}
+
+
+ )
+ )}
+
+ >
+ )}
+
+ )}
{hasPermissionToEdit && (
<>
Danger Zone
diff --git a/app/web/src/components/UserProfile/UserProfile.tsx b/app/web/src/components/UserProfile/UserProfile.tsx
index 9ea9e91..ae6cfb2 100644
--- a/app/web/src/components/UserProfile/UserProfile.tsx
+++ b/app/web/src/components/UserProfile/UserProfile.tsx
@@ -13,15 +13,18 @@ import {
// This function initializes the state management object for each of the fields
function buildFieldsConfig(fieldsConfig, user, hasPermissionToEdit) {
- return Object.fromEntries(Object.keys(fieldsConfig).map(
- (key: string): [string, FieldType] => ([key, {
- name: key,
- currentValue: user[key],
- newValue: user[key],
- isEditing: false,
- hasPermissionToEdit,
- }])
- ))
+ return Object.fromEntries(
+ Object.keys(fieldsConfig).map((key: string): [string, FieldType] => [
+ key,
+ {
+ name: key,
+ currentValue: user[key],
+ newValue: user[key],
+ isEditing: false,
+ hasPermissionToEdit,
+ },
+ ])
+ )
}
const UserProfile = ({
@@ -39,7 +42,11 @@ const UserProfile = ({
navigate(routes.user({ userName: user.userName }))
}, [currentUser])
- const initializedFields = buildFieldsConfig(fieldComponents, user, hasPermissionToEdit)
+ const initializedFields = buildFieldsConfig(
+ fieldComponents,
+ user,
+ hasPermissionToEdit
+ )
const [fields, fieldDispatch] = useReducer(fieldReducer, initializedFields)
const {
name: NameField,
diff --git a/app/web/src/components/UserProfile/userProfileConfig.tsx b/app/web/src/components/UserProfile/userProfileConfig.tsx
index cda4689..bd7b180 100644
--- a/app/web/src/components/UserProfile/userProfileConfig.tsx
+++ b/app/web/src/components/UserProfile/userProfileConfig.tsx
@@ -51,29 +51,32 @@ const ProfileKeyValue = ({
hasPermissionToEdit,
children,
bottom = false,
-} : ProfileKeyValueType) => {
+}: ProfileKeyValueType) => {
return (
- (user[field.name] && hasPermissionToEdit) &&
{
- if (field.isEditing && field.currentValue !== field.newValue) {
- save(user.userName, { [field.name]: field.newValue })
- }
- dispatch({
- type: 'SET_CURRENT_VALUE',
- payload: { field: field.name, value: field.newValue },
- })
- dispatch({ type: 'TOGGLE_EDITING', payload: field.name })
- },
- }}
- bottom={bottom}
- className="mb-4"
- >
- {children}
-
+ user[field.name] &&
+ hasPermissionToEdit && (
+
{
+ if (field.isEditing && field.currentValue !== field.newValue) {
+ save(user.userName, { [field.name]: field.newValue })
+ }
+ dispatch({
+ type: 'SET_CURRENT_VALUE',
+ payload: { field: field.name, value: field.newValue },
+ })
+ dispatch({ type: 'TOGGLE_EDITING', payload: field.name })
+ },
+ }}
+ bottom={bottom}
+ className="mb-4"
+ >
+ {children}
+
+ )
)
}
@@ -110,7 +113,7 @@ function BioField(props) {
)
}
-function MemberSinceField(props : FieldComponentPropsType) {
+function MemberSinceField(props: FieldComponentPropsType) {
return (
@@ -120,7 +123,7 @@ function MemberSinceField(props : FieldComponentPropsType) {
)
}
-function ImageField(props : FieldComponentPropsType) {
+function ImageField(props: FieldComponentPropsType) {
const { field, user, save, hasPermissionToEdit } = props
return (