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

🌎 Hack Club Bank Climate directory #850

Merged
merged 34 commits into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5b0cd34
Climate
YodaLightsabr Aug 10, 2023
93597a6
Merge branch 'main' into climate-directory
YodaLightsabr Aug 10, 2023
96cdfdc
Add Meta Tags (minus an image)
sampoder Aug 10, 2023
53481b3
Use Buttons from Figma
sampoder Aug 10, 2023
fdb5430
Force Light Mode
sampoder Aug 10, 2023
6cc9241
Add API usage
YodaLightsabr Aug 10, 2023
d8b0cf2
Changes
YodaLightsabr Aug 10, 2023
b76b5a3
Sync with my local version
sampoder Aug 10, 2023
c370c7a
Update index.js
sampoder Aug 10, 2023
fa89c20
Rejig Filtering System & Add Mobile Support
sampoder Aug 10, 2023
7390dc0
Improve Filtering UI
sampoder Aug 10, 2023
148ee83
Delete `package-lock.json`
sampoder Aug 10, 2023
6725ada
Run Prettier
sampoder Aug 10, 2023
e5421d6
Update index.js
sampoder Aug 10, 2023
d30319c
Quick Linter Fix
sampoder Aug 10, 2023
5b9b76e
Linter Warnings
sampoder Aug 10, 2023
203bce1
Merge branch 'main' into climate-directory
sampoder Aug 10, 2023
8f3801d
Filtering By Location
sampoder Aug 10, 2023
8c33827
Merge branch 'climate-directory' of https://github.com/hackclub/site …
sampoder Aug 10, 2023
2988691
Merge branch 'main' into climate-directory
sampoder Aug 10, 2023
f0f8359
changes on `/bank`
sampoder Aug 10, 2023
61bb15b
Merge branch 'climate-directory' of https://github.com/hackclub/site …
sampoder Aug 10, 2023
269bf49
Add Buttons on `/bank`
sampoder Aug 10, 2023
667cf28
Add Country Icons
sampoder Aug 10, 2023
4554279
Update index.js
sampoder Aug 10, 2023
9f13e5c
Changes
YodaLightsabr Aug 11, 2023
dfc651c
Bug fixes, finish modal - badges
YodaLightsabr Aug 12, 2023
f504f3f
`/bank`
sampoder Aug 12, 2023
1a9dc9d
Create Sparkles Folder
sampoder Aug 12, 2023
45a8820
Update Sparkles Import
sampoder Aug 12, 2023
05d7341
Add Missing "../"
sampoder Aug 12, 2023
e58bc02
Changes
YodaLightsabr Aug 12, 2023
368aa9a
Lint & format
YodaLightsabr Aug 12, 2023
b59d118
Merge branch 'main' into climate-directory
YodaLightsabr Aug 12, 2023
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
176 changes: 176 additions & 0 deletions components/bank/directory/card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
import { Card, Badge as ThemeBadge, Box, Heading, Text, Image } from 'theme-ui'
import { Organization } from '../../../pages/bank/climate'
import Tilt from '../../../components/tilt'
import Icon from '@hackclub/icons'

export const Badge = ({ badge }) =>
badge.image ? (
<ThemeBadge
as="span"
sx={{
backgroundImage: `url("${badge.image}")`,
backgroundSize: 'contain',
backgroundColor: 'unset',
backgroundRepeat: 'no-repeat',
backgroundPosition: 'center',
fontSize: 'inherit',
textShadow: 'none',
borderRadius: 5,
display: 'block',
height: 30,
width: 38
}}
>
<span style={{ opacity: '0' }}>.</span>
</ThemeBadge>
) : (
<ThemeBadge
as="span"
sx={{
bg: badge.color,
color: 'snow',
fontSize: 'inherit',
textShadow: 'none',
borderRadius: 5,
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
}}
>
<Icon glyph={badge.icon} size={30} />
</ThemeBadge>
)

const TagRow = ({ category, type, badgeNames }) => {
return (
<>
{badgeNames
.map(name => badges[name])
.map((Badge, i) => (
<Badge key={i} />
))}
</>
)
}

/**
*
* @param {{
* organization: Organization,
* showTags: boolean
* }} props
* @returns
*/
export const OrganizationCard = ({
openModal,
badges,
organization,
showTags = false
}) => (
<Tilt>
<Card
onClick={() => openModal(organization)}
rel="noopener noreferrer"
itemScope
itemType="http://schema.org/Event"
variant="event"
sx={{
justifyContent: 'center',
alignItems: 'center',
minHeight: 128,
color: 'white',
cursor: 'pointer',
textShadow: '0 1px 4px rgba(0, 0, 0, 0.375)',
textDecoration: 'none',
backgroundColor: 'black',
backgroundSize: 'cover',
backgroundPosition: 'center',
backgroundRepeat: 'no-repeat',
borderRadius: 'extra',
overflow: 'hidden',
position: 'relative',
p: 3,
height: '100%',
display: 'flex',
px: 3,
backgroundImage: `linear-gradient(rgba(0,0,0,0) 0%, rgba(0,0,0,0.375) 75%), url('${organization.branding.backgroundImage}')`,
textAlign: 'center',
flexDirection: 'column'
}}
>
<Box
sx={{
display: 'flex',
justifyContent: 'end',
alignItems: 'center',
width: '100%',
gap: 2,
flexDirection: 'row',
mb: 3
}}
>
{badges.map((badge, i) => (
<Badge key={i} badge={badge} />
))}
</Box>

{organization.branding.logo && (
<Image
src={organization.branding.logo}
alt={`${organization.name} logo`}
loading="lazy"
sx={{
minWidth: 64,
height: 64,
objectFit: 'contain',
objectPosition: 'left',
borderRadius: 'default',
mt: 'auto'
}}
/>
)}
<Heading
as={'h3'}
itemProp="name"
sx={{
fontSize: [3, 4],
mt: 2,
mb: 3,
overflowWrap: 'anywhere',
width: '100%',
display: 'block'
}}
>
{organization.name}
</Heading>
<Box
as="footer"
sx={{
mt: 'auto',
mb: 0,
width: '100%',
opacity: 0.875,
textTransform: 'none'
}}
>
<>
<Text
as="span"
itemProp="location"
itemScope
itemType="http://schema.org/Place"
>
<span itemProp="address">
{organization.raw.location.continent}
</span>
</Text>
</>
</Box>
<Box sx={{ display: 'none' }}>
<span itemProp="url">{organization.links.website}</span>
</Box>
</Card>
</Tilt>
)

export default OrganizationCard
4 changes: 2 additions & 2 deletions components/bank/landing.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ScrollHint from '../scroll-hint'
import Image from 'next/image'
import hero from '../../public/bank/bg.webp'

export default function Landing({ showButton, eventsCount }) {
export default function Landing({ showButton = true, eventsCount }) {
return (
<>
<Slide>
Expand Down Expand Up @@ -144,7 +144,7 @@ function Underline({ children }) {
return (
<span
style={{
backgroundImage: 'url(/underline.svg)',
backgroundImage: 'url(/underline-red.svg)',
backgroundRepeat: 'no-repeat',
backgroundSize: '100% 1rem',
backgroundPosition: 'bottom center'
Expand Down
18 changes: 14 additions & 4 deletions components/sparkles/money.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const MSparkles = ({
colors = ['orange', 'yellow', 'green'],
children,
sx,
path,
viewBox,
props,
...delegated
}) => {
Expand Down Expand Up @@ -58,6 +60,8 @@ const MSparkles = ({
color={sparkle.color}
size={sparkle.size}
style={sparkle.style}
path={path}
viewBox={viewBox}
/>
))}
<ChildWrapper as="strong" sx={sx} {...props}>
Expand All @@ -67,12 +71,18 @@ const MSparkles = ({
)
}

const Sparkle = ({ size, color, style }) => {
const path =
'M27 0H18V7.44119C8.56638 8.96454 2.608 15.2023 2.608 24.168C2.608 34.4553 10.2396 38.3636 18 41.2862V60.3901C14.2364 58.7919 11.8724 55.3359 11.536 50.088H0.591999C0.999374 61.0056 7.97574 68.051 18 69.933V80H27V70.2565C37.6237 69.0685 44.656 62.1891 44.656 51.912C44.656 40.3121 35.4657 36.7574 27 33.8641V16.9739C30.363 18.3007 32.5185 21.3983 32.656 26.76H43.312C43.228 15.2519 36.6759 8.81537 27 7.38614V0ZM18 16.871C14.8637 17.9425 13.072 20.2358 13.072 23.304C13.072 26.6134 15.0429 28.7127 18 30.3352V16.871ZM27 44.7132V61.0707C31.4416 60.1212 34.192 57.2657 34.192 53.16C34.192 48.9744 31.1721 46.6064 27 44.7132Z'
const Sparkle = ({ size, color, style, path, viewBox }) => {
if (!path)
path =
'M27 0H18V7.44119C8.56638 8.96454 2.608 15.2023 2.608 24.168C2.608 34.4553 10.2396 38.3636 18 41.2862V60.3901C14.2364 58.7919 11.8724 55.3359 11.536 50.088H0.591999C0.999374 61.0056 7.97574 68.051 18 69.933V80H27V70.2565C37.6237 69.0685 44.656 62.1891 44.656 51.912C44.656 40.3121 35.4657 36.7574 27 33.8641V16.9739C30.363 18.3007 32.5185 21.3983 32.656 26.76H43.312C43.228 15.2519 36.6759 8.81537 27 7.38614V0ZM18 16.871C14.8637 17.9425 13.072 20.2358 13.072 23.304C13.072 26.6134 15.0429 28.7127 18 30.3352V16.871ZM27 44.7132V61.0707C31.4416 60.1212 34.192 57.2657 34.192 53.16C34.192 48.9744 31.1721 46.6064 27 44.7132Z'
return (
<SparkleWrapper style={style}>
<SparkleSvg width={size} height={size} viewBox="0 0 82 82" fill="none">
<SparkleSvg
width={size}
height={size}
viewBox={viewBox || '0 0 82 82'}
fill="none"
>
<path fillRule="evenodd" clipRule="evenodd" d={path} fill={color} />
</SparkleSvg>
</SparkleWrapper>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"cursor-effects": "^1.0.11",
"devtools-detect": "^4.0.1",
"form-data": "^4.0.0",
"fuzzysort": "^2.0.4",
"geopattern": "^1.2.3",
"globby": "^11.0.4",
"graphql": "^16.6.0",
Expand Down
44 changes: 44 additions & 0 deletions pages/bank/climate/[region].js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import ClimateDirectory, {
regions,
fetchRawClimateOrganizations
} from './index'
import { map, find, kebabCase, startCase } from 'lodash'

const regionsWithIds = map(regions, region => ({
id: kebabCase(region.label),
...region
}))

export default function ClimateRegionalPage({ rawOrganizations, pageRegion }) {
return (
<ClimateDirectory
rawOrganizations={rawOrganizations}
pageRegion={pageRegion}
/>
)
}

export const getStaticPaths = () => {
const paths = map(map(regionsWithIds, 'id'), id => ({
params: { region: `organizations-in-${id}` }
}))

return { paths, fallback: false }
}

export const getStaticProps = async ({ params }) => {
let { region } = params
region = find(regionsWithIds, ['id', region.replace('organizations-in-', '')])

let orgs = (await fetchRawClimateOrganizations()).filter(
org => org.location.continent === region.label
)

return {
props: {
rawOrganizations: orgs,
pageRegion: region
},
revalidate: 60
}
}
Loading
Loading