Skip to content

Commit 52be467

Browse files
authored
Merge pull request #17 from TomPlum/develop
Demo loader and NPM publish fixes in CI
2 parents 91005e8 + 69e1c81 commit 52be467

7 files changed

Lines changed: 101 additions & 21 deletions

File tree

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ jobs:
3030
with:
3131
folder: ./packages/demo/storybook-static
3232

33+
- name: Authenticate with NPM
34+
run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
35+
env:
36+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
37+
3338
- name: Publish to NPM
3439
run: npm publish --workspace=@tomplum/react-git-log --access public
3540
env:

packages/demo/src/GitLog.stories.module.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
box-sizing: border-box;
44
}
55

6+
.loading {
7+
width: 100%;
8+
height: calc(100vh - 110px);
9+
display: flex;
10+
justify-content: center;
11+
align-items: center;
12+
}
13+
614
.table {
715
>thead > tr > th {
816
font-weight: 700;

packages/demo/src/GitLog.stories.tsx

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { fetchLogEntryData } from 'utils/fetchLogEntryData'
1414
import { ThemeToggle } from 'components/ThemeToggle'
1515
import { rainbow } from 'themes.ts'
1616
import { RepositorySelector } from 'components/RepositorySelector'
17+
import { Loading } from 'components/Loading'
1718

1819
// TODO: once mono repo in place, extract types and components from here
1920

@@ -217,10 +218,6 @@ export const Default: Story = {
217218
setColours(selected)
218219
}, [])
219220

220-
if (loading || !entries) {
221-
return <div>Loading...</div>
222-
}
223-
224221
const backgroundColour = theme === 'dark' ? '#1a1a1a' : 'white'
225222
const textColour = theme === 'dark' ? 'white' : '#1a1a1a'
226223

@@ -271,23 +268,31 @@ export const Default: Story = {
271268
</div>
272269
</div>
273270

274-
<GitLog
275-
{...args}
276-
colours={colours.colors}
277-
entries={entries}
278-
theme={theme}
279-
currentBranch={branch}
280-
paging={{
281-
page: args.page ?? 0,
282-
size: args.pageSize ?? entries.length
283-
}}
284-
classes={{
285-
containerStyles: {
286-
background: backgroundColour
287-
},
288-
logTableClass: styles.table
289-
}}
290-
/>
271+
{loading && (
272+
<div className={styles.loading}>
273+
<Loading theme={theme} />
274+
</div>
275+
)}
276+
277+
{!loading && entries && (
278+
<GitLog
279+
{...args}
280+
colours={colours.colors}
281+
entries={entries}
282+
theme={theme}
283+
currentBranch={branch}
284+
paging={{
285+
page: args.page ?? 0,
286+
size: args.pageSize ?? entries.length
287+
}}
288+
classes={{
289+
containerStyles: {
290+
background: backgroundColour
291+
},
292+
logTableClass: styles.table
293+
}}
294+
/>
295+
)}
291296
</div>
292297
)
293298
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.container {
2+
height: 100%;
3+
width: 100%;
4+
display: flex;
5+
flex-direction: column;
6+
align-items: center;
7+
justify-content: center;
8+
gap: 30px;
9+
}
10+
11+
.loading {
12+
height: 60px;
13+
aspect-ratio: 2;
14+
border-bottom: 3px solid #0000;
15+
position: relative;
16+
animation: l3-0 .75s linear infinite;
17+
}
18+
19+
.loading:before {
20+
content: "";
21+
position: absolute;
22+
inset: auto 42.5% 0;
23+
aspect-ratio: 1;
24+
border-radius: 50%;
25+
background: #CF4647;
26+
animation: l3-1 .75s cubic-bezier(0,900,1,900) infinite;
27+
}
28+
29+
@keyframes l3-0 {
30+
to {background-position: -125% 100%}
31+
}
32+
33+
@keyframes l3-1 {
34+
0%,2% {bottom: 0%}
35+
98%,to {bottom:.1%}
36+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import styles from './Loading.module.scss'
2+
import { LoadingProps } from './types'
3+
4+
export const Loading = ({ theme }: LoadingProps) => {
5+
const lineColour = theme === 'dark' ? ['#f8f8f8', '#0000'] : ['#524656', '#0000']
6+
7+
return (
8+
<div className={styles.container}>
9+
<div
10+
style={{
11+
background: `linear-gradient(90deg,${lineColour[0]} 50%,${lineColour[1]} 0) -25% 100%/50% 3px repeat-x border-box`
12+
}}
13+
className={styles.loading}
14+
/>
15+
16+
<span style={{ color: lineColour[0] }}>Loading...</span>
17+
</div>
18+
)
19+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './types'
2+
export * from './Loading'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { ThemeMode } from '@tomplum/react-git-log'
2+
3+
export interface LoadingProps {
4+
theme: ThemeMode
5+
}

0 commit comments

Comments
 (0)