Skip to content

Commit

Permalink
Prettier integration (#83)
Browse files Browse the repository at this point in the history
Co-authored-by: Christy Presler <[email protected]>
  • Loading branch information
cpresler and cpresler authored Apr 16, 2024
1 parent 75e875d commit 81b740e
Show file tree
Hide file tree
Showing 65 changed files with 511 additions and 639 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup

- run: bun run tsc
- run: bun run test
- run: bun run build
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup

- run: bun run tsc
- run: bun run test
- run: bun run build
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# ignore artifacts
dist
.lockb
.github
.prettierrc
**/*.json
**/*.md
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ While running Live Reload, go to `Menu > Widgets > Development > Import widget f

### Tests

To typecheck the widget run:
Before creating a pull request run prettier to ensure code formatting and a typecheck on the widget. Run:

```sh
$ bun run tsc
$ bun run test
```

## Contributor Covenant Code of Conduct
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@figma/widget-typings": "*",
"date-fns": "^3.6.0",
"esbuild": "*",
"prettier": "3.2.5",
"typescript": "*"
},
"contributors": [
Expand All @@ -17,7 +18,7 @@
"license": "MIT",
"scripts": {
"build": "esbuild widget-src/Widget.tsx --bundle --outfile=dist/code.js --target=es6",
"tsc": "tsc --noEmit --noUnusedLocals --noUnusedParameters --skipLibCheck -p widget-src",
"test": "prettier . --write && tsc --noEmit --noUnusedLocals --noUnusedParameters --skipLibCheck -p widget-src",
"watch": "bun run build -- --watch"
}
}
2 changes: 1 addition & 1 deletion widget-src/Widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function Widget() {
break;
}
setUpdatedDate(Date.now());
}
},
);

useEffect(() => {
Expand Down
11 changes: 2 additions & 9 deletions widget-src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,7 @@ interface ButtonProps {
error?: boolean;
}

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

export const Button = ({ label, hideLabel = false, action, iconSrc, error = false }: ButtonProps) => {
if (error) {
return (
<AutoLayout
Expand Down Expand Up @@ -66,7 +59,7 @@ export const Button = ({
{label}
</Text>
</AutoLayout>
)
);
}

return (
Expand Down
12 changes: 10 additions & 2 deletions widget-src/components/ChangeLogEmpty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const ChangeLogEmpty = ({ isLocked }: { isLocked: boolean }) => (
letterSpacing={FONT.letterSpacing.sm}
textCase="upper"
>
unlock widget from property menu to add your first change.
unlock widget from property menu to add your first change.
</Text>
) : (
<>
Expand All @@ -53,7 +53,15 @@ export const ChangeLogEmpty = ({ isLocked }: { isLocked: boolean }) => (
>
no changes found in log. add your first change here
</Text>
<SVG name="Arrow" x={570} y={-4} positioning="absolute" height={SPACE.md} width={SPACE.lg} src={<HelpArrow />} />
<SVG
name="Arrow"
x={570}
y={-4}
positioning="absolute"
height={SPACE.md}
width={SPACE.lg}
src={<HelpArrow />}
/>
</>
)}
</AutoLayout>
Expand Down
41 changes: 22 additions & 19 deletions widget-src/components/ChangeLogList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,29 @@ export const ChangeLogList = ({
horizontal: PADDING.none,
}}
>
{changeLogs.entries().sort((a, b) => b[1].createdDate - a[1].createdDate ).map((changeLogArr, index) => {
const changeLogId = changeLogArr[0];
const changeLog = changeLogArr[1];
{changeLogs
.entries()
.sort((a, b) => b[1].createdDate - a[1].createdDate)
.map((changeLogArr, index) => {
const changeLogId = changeLogArr[0];
const changeLog = changeLogArr[1];

return (
<ChangeLogRow
key={changeLogId}
changeLogId={changeLogId}
changeLog={changeLog}
isLastRow={index === changeLogIds.length - 1}
updateChange={changes => changeLogs.set(changeLogId, { ...changeLog, ...changes })}
updateChangeState={changes => changeLogs.set(changeLogId, { ...changeLog, state: { ... changes }})}
updateOtherStates={updateOtherStates}
deleteChange={() => deleteChange(changeLogId)}
setUpdatedDate={setUpdatedDate}
showTypes={showTypes}
locked={isLocked}
/>
);
})}
return (
<ChangeLogRow
key={changeLogId}
changeLogId={changeLogId}
changeLog={changeLog}
isLastRow={index === changeLogIds.length - 1}
updateChange={changes => changeLogs.set(changeLogId, { ...changeLog, ...changes })}
updateChangeState={changes => changeLogs.set(changeLogId, { ...changeLog, state: { ...changes } })}
updateOtherStates={updateOtherStates}
deleteChange={() => deleteChange(changeLogId)}
setUpdatedDate={setUpdatedDate}
showTypes={showTypes}
locked={isLocked}
/>
);
})}
</AutoLayout>
);
};
1 change: 0 additions & 1 deletion widget-src/components/ChangeLogRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const ChangeLogRow = ({
showTypes,
locked,
}: ChangeLogRowProps) => {

return (
<AutoLayout
key={changeLogId}
Expand Down
3 changes: 1 addition & 2 deletions widget-src/components/header/Description.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const Description = ({
fontSize={FONT.size.lg}
hidden={!description}
>
{descriptionText || "Description..."}
{descriptionText || 'Description...'}
</Text>
) : (
<Input
Expand All @@ -62,7 +62,6 @@ export const Description = ({
fontSize={FONT.size.lg}
hidden={!description}
/>

)}
</AutoLayout>
);
Expand Down
1 change: 0 additions & 1 deletion widget-src/components/header/Meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ export const Meta = ({
>
<SVG name="Add" height={SPACE.sm} width={SPACE.sm} src={<ActionAddIcon />} />
</AutoLayout>

)}
</AutoLayout>
)}
Expand Down
8 changes: 1 addition & 7 deletions widget-src/components/header/MetaValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ interface MetaValueProps {
locked: boolean;
}

export const MetaValue = ({
label,
value,
setValue,
setUpdatedDate,
locked,
}: MetaValueProps) => {
export const MetaValue = ({ label, value, setValue, setUpdatedDate, locked }: MetaValueProps) => {
return (
<AutoLayout
name="MetaValue"
Expand Down
11 changes: 2 additions & 9 deletions widget-src/components/header/Name.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ interface NameProps {
locked: boolean;
}

export const Name = ({
name,
nameText,
setNameText,
setUpdatedDate,
locked,
}: NameProps) => {
export const Name = ({ name, nameText, setNameText, setUpdatedDate, locked }: NameProps) => {
return (
<AutoLayout name="NameWrapper" overflow="visible" direction="vertical" width="fill-parent" hidden={!name}>
{locked ? (
Expand All @@ -31,7 +25,7 @@ export const Name = ({
fontWeight={FONT.weight.bold}
hidden={!name}
>
{nameText || "Name..."}
{nameText || 'Name...'}
</Text>
) : (
<Input
Expand All @@ -53,7 +47,6 @@ export const Name = ({
value={nameText}
hidden={!name}
/>

)}
</AutoLayout>
);
Expand Down
17 changes: 5 additions & 12 deletions widget-src/components/log/AddLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,9 @@ interface AddLinkProps {
updateChangeState: (changes: Partial<ChangeLogState>) => void;
}

export const AddLink = ({
changeLog,
updateChangeState,
}: AddLinkProps) => {
export const AddLink = ({ changeLog, updateChangeState }: AddLinkProps) => {
return (
<AutoLayout
width="fill-parent"
horizontalAlignItems="end"
verticalAlignItems="center"
>
<AutoLayout width="fill-parent" horizontalAlignItems="end" verticalAlignItems="center">
{changeLog.links && changeLog.links.length > 7 ? (
<Text
fill={COLOR.greyDark}
Expand All @@ -38,10 +31,10 @@ export const AddLink = ({
updateChangeState({
...changeLog.state,
showLinkForm: true,
})
});
}}
/>
)}
</AutoLayout>
)
}
);
};
11 changes: 3 additions & 8 deletions widget-src/components/log/DateRangeDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@ const { widget } = figma;
const { AutoLayout, Text } = widget;

interface DateRangeProps {
timestamp: number,
editedTimestamp: number,
timestamp: number;
editedTimestamp: number;
editCount: number;
}

export const DateRange = ({
timestamp,
editedTimestamp,
editCount,
}: DateRangeProps) => {

export const DateRange = ({ timestamp, editedTimestamp, editCount }: DateRangeProps) => {
return (
<AutoLayout name="Log Date" overflow="visible" spacing={GAP.md} verticalAlignItems="center">
<Text
Expand Down
Loading

0 comments on commit 81b740e

Please sign in to comment.