-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(slice-machine): add GitHub settings page
- Loading branch information
Showing
35 changed files
with
1,513 additions
and
655 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export type Owner = { | ||
export type GitOwner = { | ||
provider: "gitHub"; | ||
id: string; | ||
name: string; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1 @@ | ||
import React from "react"; | ||
import Head from "next/head"; | ||
import { BaseStyles } from "theme-ui"; | ||
import { | ||
AppLayout, | ||
AppLayoutBreadcrumb, | ||
AppLayoutContent, | ||
AppLayoutHeader, | ||
} from "@components/AppLayout"; | ||
import { ConnectGitRepository } from "@src/features/git/ConnectGitRepository/ConnectGitRepository"; | ||
|
||
const Settings: React.FC = () => { | ||
return ( | ||
<> | ||
<Head> | ||
<title>Settings - Slice Machine</title> | ||
</Head> | ||
<AppLayout> | ||
<AppLayoutHeader> | ||
<AppLayoutBreadcrumb folder="Settings" /> | ||
</AppLayoutHeader> | ||
<AppLayoutContent> | ||
<BaseStyles sx={{ display: "flex", flexDirection: "column" }}> | ||
<ConnectGitRepository /> | ||
</BaseStyles> | ||
</AppLayoutContent> | ||
</AppLayout> | ||
</> | ||
); | ||
}; | ||
|
||
export default Settings; | ||
export { SettingsPage as default } from "@src/features/settings/SettingsPage"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
plugins: { | ||
"postcss-flexbugs-fixes": true, | ||
"postcss-preset-env": { | ||
autoprefixer: { flexbox: "no-2009" }, | ||
features: { "custom-properties": false, "nesting-rules": true }, | ||
stage: 3, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/slice-machine/src/components/RelativeTime/RelativeTime.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { RelativeTime } from "./RelativeTime"; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
const meta = { | ||
component: RelativeTime, | ||
argTypes: { | ||
date: { control: "date" }, | ||
}, | ||
} satisfies Meta<typeof RelativeTime>; | ||
|
||
export default meta; | ||
|
||
export const Default = { | ||
args: { | ||
date: new Date("1 Jan 2024"), | ||
}, | ||
render: ({ date, ...otherArgs }) => ( | ||
// The `date` control converts the `date` arg into a UNIX timestamp. That's | ||
// why we need to convert it back into a `Date` object. | ||
<RelativeTime {...otherArgs} date={new Date(date)} /> | ||
), | ||
} satisfies Story; |
40 changes: 40 additions & 0 deletions
40
packages/slice-machine/src/components/RelativeTime/RelativeTime.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Text } from "@prismicio/editor-ui"; | ||
import type { FC } from "react"; | ||
|
||
type RelativeTimeProps = { | ||
date: Date; | ||
}; | ||
|
||
export const RelativeTime: FC<RelativeTimeProps> = ({ | ||
date, | ||
...otherProps | ||
}) => ( | ||
<Text {...otherProps} color="inherit" variant="inherit"> | ||
{formatRelativeTime(date)} | ||
</Text> | ||
); | ||
|
||
const rtf = new Intl.RelativeTimeFormat("en", { | ||
numeric: "auto", | ||
style: "narrow", | ||
}); | ||
|
||
function formatRelativeTime(date: Date, now = new Date()): string { | ||
return rtf.format(differenceInCalendarDays(date, now), "day"); | ||
} | ||
|
||
const millisecondsInDay = 1_000 * 60 * 60 * 24; | ||
|
||
// Adapted from: https://github.com/date-fns/date-fns/blob/6f44a167e71053999c10aa9462d7f0c52fec0faa/src/differenceInCalendarDays/index.ts. | ||
function differenceInCalendarDays(dateLeft: Date, dateRight: Date): number { | ||
const startOfDayLeft = startOfDay(dateLeft); | ||
const startOfDayRight = startOfDay(dateRight); | ||
return Math.round((+startOfDayLeft - +startOfDayRight) / millisecondsInDay); | ||
} | ||
|
||
// Adapted from: https://github.com/date-fns/date-fns/blob/6f44a167e71053999c10aa9462d7f0c52fec0faa/src/startOfDay/index.ts. | ||
function startOfDay(date: Date): Date { | ||
const newDate = new Date(date); | ||
newDate.setHours(0, 0, 0, 0); | ||
return newDate; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { RelativeTime } from "./RelativeTime"; |
15 changes: 0 additions & 15 deletions
15
packages/slice-machine/src/features/git/ConnectGitRepository/ConnectGitRepository.module.css
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.