Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Editing Flow and Manual Dates #77

Merged
merged 27 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
19fd61c
show log types by default
cpresler Feb 16, 2024
e563191
relabel name text block
cpresler Feb 23, 2024
179996b
add editing state and apply toggle to change log type display
cpresler Feb 23, 2024
5e06005
add editing button toggle and remove 'isEditable' from changelog row
cpresler Feb 28, 2024
5f6d893
fix state override bug in link form submission
cpresler Feb 28, 2024
1141ff2
move 'add link' into editing state and add delete button
cpresler Feb 28, 2024
ea44ad8
add trash icon as delete and move x to close icon. show/hide link del…
cpresler Feb 28, 2024
8e25ed1
make new logs editable
cpresler Feb 28, 2024
5f17baa
move add link into editing and disable updateOthers as part of the ty…
cpresler Mar 1, 2024
c81a013
refactor changelog display and editing into separate components and r…
cpresler Mar 1, 2024
5d0d2f7
add 'updates' data within state, and move link deletion into editing …
cpresler Mar 5, 2024
9f153ae
move changelog state into it's own type and add updateChangeStates to…
cpresler Mar 14, 2024
cdc9e01
fix spots where editing data was wiping away other update, or where e…
cpresler Mar 14, 2024
e7ed1e5
refactor updateOtherStates into Widget level so that adding a widget …
cpresler Mar 14, 2024
c580c92
refactor dateRange to handle date editing
cpresler Mar 15, 2024
d786170
date editing error handling, only allow date changes (no time changes…
cpresler Mar 18, 2024
9960295
sort changelogs by created date
cpresler Mar 18, 2024
4f3e746
push missed editing save changes
cpresler Mar 18, 2024
96eebfc
refactor dateRange to include time editing
cpresler Mar 21, 2024
8e574b2
split DateRange into DateRangeForm and DateRangeDisplay
cpresler Mar 21, 2024
5fe5982
change save/delete button label to be more clear and in line with lan…
cpresler Mar 22, 2024
140a085
add error state button to editing state
cpresler Apr 12, 2024
919b9b7
standardizing error messaging
cpresler Apr 12, 2024
0cefd9e
remove console logs from production
cpresler Apr 12, 2024
7765c67
remove grey background from error button
cpresler Apr 12, 2024
80eb141
remove '12 hour' from error message
cpresler Apr 12, 2024
5cd3e38
cleaning up button icons in edit form
cpresler Apr 12, 2024
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
22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
{
"name": "figlog",
"version": "1.0.0",
"description": "The easiest and most efficient way to document team decisions and the evolution of your changes in Figma.",
"repository": "https://github.com/FormidableLabs/figlog.git",
"scripts": {
"build": "esbuild widget-src/Widget.tsx --bundle --outfile=dist/code.js --target=es6",
"tsc": "tsc --noEmit -p widget-src",
"watch": "bun run build -- --watch"
},
"contributors": [
"Ryan Srofe <rsrofe@gmail.com>"
],
"license": "MIT",
"devDependencies": {
"@figma/plugin-typings": "*",
"@figma/widget-typings": "*",
"date-fns": "^3.6.0",
"esbuild": "*",
"typescript": "*"
},
"contributors": [
"Ryan Srofe <rsrofe@gmail.com>",
"Christy Presler <christy.presler@nearform.com>"
],
"description": "The easiest and most efficient way to document team decisions and the evolution of your changes in Figma.",
"license": "MIT",
"scripts": {
"build": "esbuild widget-src/Widget.tsx --bundle --outfile=dist/code.js --target=es6",
"tsc": "tsc --noEmit -p widget-src",
"watch": "bun run build -- --watch"
}
}
26 changes: 21 additions & 5 deletions widget-src/Widget.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeLog } from './types/ChangeLog';
import { ChangeLog, ChangeLogState } from './types/ChangeLog';
import { Header } from './components/Header';
import { Footer } from './components/Footer';
import { WidgetContainer } from './components/WidgetContainer';
Expand All @@ -15,7 +15,7 @@ function Widget() {
const [showStatus, setShowStatus] = useSyncedState('showStatus', '0');
const [showVersion, setShowVersion] = useSyncedState('showVersion', false);
const [showBranding, setShowBranding] = useSyncedState('showBradning', true); // fixing the typo messes with branding state on existing widgets
const [showLogTypes, setShowLogTypes] = useSyncedState('showLogTypes', false);
const [showLogTypes, setShowLogTypes] = useSyncedState('showLogTypes', true);
// Meta Data
const [createdDate, setCreatedDate] = useSyncedState('createdDate', 0);
const [updatedDate, setUpdatedDate] = useSyncedState('updatedDate', 0);
Expand All @@ -25,22 +25,38 @@ function Widget() {
const [changeIds, setChangeIds] = useSyncedState<string[]>('changeKeys', []);
const changeLogs = useSyncedMap<ChangeLog>('changes');

const updateOtherStates = (currentChangeId: string, changes: Partial<ChangeLogState>) => {
changeIds.map((id: string) => {
if (id !== currentChangeId) {
const otherLog = changeLogs.get(id) as ChangeLog;
changeLogs.set(id, { ...otherLog, state: { ...otherLog.state, ...changes }})
}
})
}

const addChange = (changeToAdd: string) => {
changeLogs.set(changeToAdd, {
change: '',
type: 'none',
createdDate: Date.now(),
editedDate: Date.now(),
user: currentUser,
links: [],
editCount: 0,
state: {
editing: true,
showTypeMenu: false,
showLinkForm: false,
linkFormError: { label: false, url: false }
updates: {
change: '',
type: 'none',
createdDate: Date.now(),
linkFormError: { label: false, url: false }
}
},
links: [],
});
setChangeIds([changeToAdd, ...changeIds]);
updateOtherStates(changeToAdd, { editing: false })
setUpdatedDate(Date.now());
};
const deleteChange = (changeToDelete: string) => {
Expand Down Expand Up @@ -164,7 +180,7 @@ function Widget() {
<ChangeLogList
changeLogs={changeLogs}
changeLogIds={changeIds}
adminId={adminId}
updateOtherStates={updateOtherStates}
deleteChange={deleteChange}
setUpdatedDate={setUpdatedDate}
showTypes={showLogTypes}
Expand Down
54 changes: 53 additions & 1 deletion widget-src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,67 @@ interface ButtonProps {
hideLabel?: boolean;
action: () => void;
iconSrc?: string;
error?: boolean;
}

export const Button = ({
label,
hideLabel = false,
action,
iconSrc
iconSrc,
error = false,
}: ButtonProps) => {

if (error) {
return (
<AutoLayout
name={`error-button-${label}`}
fill={COLOR.white}
cornerRadius={RADIUS.sm}
overflow="visible"
spacing={GAP.sm}
padding={PADDING.xs}
stroke={COLOR.red}
strokeWidth={SPACE.one}
horizontalAlignItems="center"
verticalAlignItems="center"
>
{iconSrc && (
<Frame name="Icon" overflow="visible" width={SPACE.xxs} height={SPACE.xxs}>
<SVG
name={label}
x={{
type: 'center',
offset: PADDING.none,
}}
y={{
type: 'center',
offset: PADDING.none,
}}
height={SPACE.xs}
width={SPACE.xs}
src={iconSrc}
/>
</Frame>
)}
<Text
name="Label"
fill={COLOR.red}
verticalAlignText="center"
lineHeight={FONT.lineHeight.xs}
fontFamily={FONT.family}
fontSize={FONT.size.xs}
letterSpacing={FONT.letterSpacing.sm}
fontWeight={FONT.weight.bold}
textCase="upper"
hidden={hideLabel}
>
{label}
</Text>
</AutoLayout>
)
}

return (
<AutoLayout
name={`button-${label}`}
Expand Down
32 changes: 9 additions & 23 deletions widget-src/components/ChangeLogList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeLog } from '../types/ChangeLog';
import { ChangeLog, ChangeLogState } from '../types/ChangeLog';
import { PADDING } from '../utilities/Styles';
import { ChangeLogRow } from './ChangeLogRow';

Expand All @@ -8,7 +8,7 @@ const { AutoLayout, useEffect } = widget;
interface ChangeLogListProps {
changeLogIds: string[];
changeLogs: SyncedMap<ChangeLog>;
adminId: string;
updateOtherStates: (changeId: string, changes: Partial<ChangeLogState>) => void;
deleteChange: (changeId: string) => void;
setUpdatedDate: (updatedDate: number) => void;
showTypes: boolean;
Expand All @@ -17,13 +17,13 @@ interface ChangeLogListProps {
export const ChangeLogList = ({
changeLogIds,
changeLogs,
// adminId,
updateOtherStates,
deleteChange,
setUpdatedDate,
showTypes
}: ChangeLogListProps) => {
useEffect(() => {
console.log('ChangeLogs', changeLogs.entries());
// console.log('ChangeLogs', changeLogs.entries());
});

return (
Expand All @@ -37,16 +37,9 @@ export const ChangeLogList = ({
horizontal: PADDING.none,
}}
>
{changeLogIds.map((changeLogId, index) => {
const changeLog = changeLogs.get(changeLogId) as ChangeLog;

function isEditable(): boolean {
// if widget admin
// if (adminId === currentUser?.id) { return true; }
// if changeLog owner
// if (changeLog?.user?.id === currentUser?.id) { return true; }
return true;
}
{changeLogs.entries().sort((a, b) => b[1].createdDate - a[1].createdDate ).map((changeLogArr, index) => {
const changeLogId = changeLogArr[0];
const changeLog = changeLogArr[1];

return (
<ChangeLogRow
Expand All @@ -55,17 +48,10 @@ export const ChangeLogList = ({
changeLog={changeLog}
isLastRow={index === changeLogIds.length - 1}
updateChange={changes => changeLogs.set(changeLogId, { ...changeLog, ...changes })}
updateOthers={changes => {
changeLogIds.map((id) => {
if (id !== changeLogId) {
const otherLog = changeLogs.get(id) as ChangeLog;
changeLogs.set(id, { ...otherLog, ...changes })
}
})
}}
updateChangeState={changes => changeLogs.set(changeLogId, { ...changeLog, state: { ... changes }})}
updateOtherStates={updateOtherStates}
deleteChange={() => deleteChange(changeLogId)}
setUpdatedDate={setUpdatedDate}
isEditable={isEditable()}
showTypes={showTypes}
/>
);
Expand Down
Loading
Loading