WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 9c56344

Browse files
committed
Add more resume space & resume dev mode
1 parent b7096f7 commit 9c56344

File tree

11 files changed

+149
-15
lines changed

11 files changed

+149
-15
lines changed

workspaces/gql-types/src/index.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11005,6 +11005,48 @@ export type IndexBannerQuery = {
1100511005
fullName: string
1100611006
headline: string
1100711007
about: string
11008+
location: string
11009+
phoneNumber: string
11010+
email: string
11011+
}>
11012+
educations: Array<{
11013+
__typename?: 'GraphCMS_Education'
11014+
id: string
11015+
school: string
11016+
degree?: string | null | undefined
11017+
areaOfStudy: string
11018+
startDate: any
11019+
endDate?: any | null | undefined
11020+
}>
11021+
skills: Array<{
11022+
__typename?: 'GraphCMS_Skill'
11023+
id: string
11024+
title: string
11025+
yearsOfExperience: number
11026+
}>
11027+
experiences: Array<{
11028+
__typename?: 'GraphCMS_Experience'
11029+
id: string
11030+
company: string
11031+
position: string
11032+
startDate: any
11033+
endDate?: any | null | undefined
11034+
description: { __typename?: 'GraphCMS_RichText'; html: string }
11035+
}>
11036+
publications: Array<{
11037+
__typename?: 'GraphCMS_Publication'
11038+
id: string
11039+
title: string
11040+
link: string
11041+
date: any
11042+
}>
11043+
conferences: Array<{
11044+
__typename?: 'GraphCMS_Conference'
11045+
id: string
11046+
title: string
11047+
topic: string
11048+
link: string
11049+
date: any
1100811050
}>
1100911051
}
1101011052
}

workspaces/landing/src/components/atoms/button/Button.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import { buttonCss } from './styles'
55

66
export interface Props extends EmotionProps, HTMLAttributes<HTMLButtonElement> {
77
inverted?: boolean
8+
disabled?: boolean
89
}
910

1011
const Button = forwardRef<HTMLButtonElement, Props>(
11-
({ children, inverted = false, ...rest }, ref) => (
12-
<button ref={ref} css={buttonCss({ inverted })} {...rest}>
12+
({ children, inverted = false, disabled = false, ...rest }, ref) => (
13+
<button ref={ref} css={buttonCss({ inverted, disabled })} {...rest}>
1314
{children}
1415
</button>
1516
)

workspaces/landing/src/components/atoms/button/ButtonLink.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import { buttonCss } from './styles'
44

55
export interface Props extends LinkProps {
66
inverted?: boolean
7+
disabled?: boolean
78
to: LinkProps['to']
89
}
910

1011
const ButtonLink = forwardRef<HTMLAnchorElement, Props>(
11-
({ children, inverted = false, ...rest }, ref) => (
12+
({ children, inverted = false, disabled = false, ...rest }, ref) => (
1213
<Link
1314
ref={ref}
14-
css={buttonCss({ inverted })}
15+
css={buttonCss({ inverted, disabled })}
1516
{...rest}
1617
color={inverted ? 'blue' : 'beige'}
1718
inheritFontSize

workspaces/landing/src/components/atoms/button/styles.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import { theme } from '@teimurjan/utils'
33

44
interface Args {
55
inverted?: boolean
6+
disabled?: boolean
67
}
78

8-
export const buttonCss = ({ inverted }: Args) => css`
9+
export const buttonCss = ({ inverted, disabled }: Args) => css`
10+
pointer-events: ${disabled ? 'none' : 'auto'};
911
border: none;
1012
background: ${inverted
1113
? `linear-gradient(to right, ${theme.colors.button.beigeDarken} 50%, ${theme.colors.button.beige} 50%)`

workspaces/landing/src/components/organisms/index-banner/IndexBanner.tsx

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import { css, keyframes } from '@emotion/react'
33
import { Fragment } from 'react'
44
import { graphql, useStaticQuery } from 'gatsby'
55
import { IndexBannerQuery } from '@teimurjan/gql-types'
6+
import Resume, { PDFDownloadLink } from '@teimurjan/resume'
67
import { theme } from '@teimurjan/utils'
78
import { Banner } from '../../molecules'
89
import { Button, Square } from '../../atoms'
10+
import { useLazyInitialization } from '../../../hooks'
911

1012
const roll = (rotation: number) => keyframes`
1113
0% {
@@ -24,17 +26,62 @@ const query = graphql`
2426
fullName
2527
headline
2628
about
29+
location
30+
phoneNumber
31+
email
32+
}
33+
educations(orderBy: startDate_DESC) {
34+
id
35+
school
36+
degree
37+
areaOfStudy
38+
startDate
39+
endDate
40+
}
41+
skills(orderBy: yearsOfExperience_DESC) {
42+
id
43+
title
44+
yearsOfExperience
45+
}
46+
experiences(orderBy: startDate_DESC) {
47+
id
48+
company
49+
position
50+
startDate
51+
endDate
52+
description {
53+
html
54+
}
55+
}
56+
publications {
57+
id
58+
title
59+
link
60+
date
61+
}
62+
conferences {
63+
id
64+
title
65+
topic
66+
link
67+
date
2768
}
2869
}
2970
}
3071
`
3172

3273
const IndexBanner = () => {
74+
const data = useStaticQuery<IndexBannerQuery>(query)
3375
const {
3476
gcms: {
3577
bios: [{ fullName, headline, about }],
3678
},
37-
} = useStaticQuery<IndexBannerQuery>(query)
79+
} = data
80+
const { value: shouldGeneratePDFInBrowser, isInitialized } =
81+
useLazyInitialization(
82+
process.env.NODE_ENV === 'development' && typeof window !== 'undefined',
83+
false
84+
)
3885

3986
return (
4087
<Banner
@@ -45,9 +92,33 @@ const IndexBanner = () => {
4592
subtitle={headline}
4693
description={about}
4794
button={
48-
<Button.Link type="external" to="/resume.pdf">
49-
Get resume
50-
</Button.Link>
95+
shouldGeneratePDFInBrowser && isInitialized ? (
96+
<PDFDownloadLink
97+
document={<Resume {...data} />}
98+
fileName="resume.pdf"
99+
>
100+
{({ url, loading }) => (
101+
<Button
102+
onClick={(e) => {
103+
// Prevent download action to be triggered
104+
e.stopPropagation()
105+
e.preventDefault()
106+
107+
if (url) {
108+
window.open(url, '_blank')
109+
}
110+
}}
111+
disabled={loading}
112+
>
113+
Get resume
114+
</Button>
115+
)}
116+
</PDFDownloadLink>
117+
) : (
118+
<Button.Link type="external" to="/resume.pdf">
119+
Get resume
120+
</Button.Link>
121+
)
51122
}
52123
image={
53124
<Fragment>

workspaces/landing/src/hooks/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export { default as useMedia } from './use-media'
22
export { default as useElementVisibility } from './use-element-visibility'
33
export { default as useWindowScroll } from './use-window-scroll'
44
export { default as useOnClickOutside } from './use-on-click-outside'
5+
export { default as useLazyInitialization } from './use-lazy-initialization'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { useState, useEffect } from 'react'
2+
3+
const useLazyInitialization = <T>(actualValue: T, defaultValue: T) => {
4+
const [trigger, setTrigger] = useState(false)
5+
6+
useEffect(() => {
7+
const timeoutID = setTimeout(() => setTrigger(true), 0)
8+
return () => clearTimeout(timeoutID)
9+
}, [])
10+
11+
const value = trigger ? actualValue : defaultValue
12+
13+
return { value, isInitialized: trigger }
14+
}
15+
16+
export default useLazyInitialization

workspaces/resume/src/Resume.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ const styles = StyleSheet.create({
4141
},
4242
wrapper: {
4343
width: '100%',
44-
padding: '0 40px',
44+
padding: '0 20px',
4545
},
4646
container: {
4747
backgroundColor: theme.colors.resume.white,
48-
padding: '20px 20px',
48+
padding: '16px 20px',
4949
width: '100%',
5050
height: '100%',
5151
},

workspaces/resume/src/components/contacts/Contacts.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Text, View, StyleSheet } from '@react-pdf/renderer'
22
import { theme } from '@teimurjan/utils'
33
import MapPinIcon from '../map-pin-icon'
44
import MailIcon from '../mail-icon'
5-
import PhoneIcon from '../mail-icon'
5+
import PhoneIcon from '../phone-icon'
66

77
const styles = StyleSheet.create({
88
contactsSection: {

workspaces/resume/src/components/header/Header.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ const styles = StyleSheet.create({
55
header: {
66
backgroundColor: theme.colors.resume.green,
77
width: '100%',
8-
padding: '20px 40px 0 40px',
8+
padding: '20px 20px 0 20px',
99
textAlign: 'center',
1010
textTransform: 'uppercase',
1111
fontFamily: 'ShareTechMono',
1212
},
1313
headerContainer: {
1414
width: '100%',
15-
padding: '20px 50px',
15+
padding: '10px 40px',
1616
backgroundColor: theme.colors.resume.white,
1717
},
1818
headerTitle: {

0 commit comments

Comments
 (0)