File size: 5,212 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
import {
  Box,
  BoxProps,
  Button,
  Center,
  Container,
  Flex,
  Group,
  HStack,
  Image,
  Span,
  Stack,
  Text,
} from "@chakra-ui/react"
import { Blob } from "./blob"
import {
  GoldSponsorIcon,
  OpenCollective,
  Patreon,
  SilverSponsorIcon,
} from "./icons"
import { SponsorImage } from "./sponsor-image"
import { BlitzHeading, HighlightHeading } from "./typography"

const CallToActions = () => (
  <Group gap="5">
    <Button
      asChild
      colorPalette="teal"
      size="lg"
      _icon={{ height: "5", width: "auto" }}
    >
      <a href="https://opencollective.com/chakra-ui">
        <OpenCollective />
        Sponsor
      </a>
    </Button>
    <Button
      asChild
      colorPalette="teal"
      size="lg"
      variant="outline"
      _icon={{ height: "5", width: "auto" }}
    >
      <a
        target="_blank"
        rel="noopener"
        href="https://www.patreon.com/segunadebayo"
      >
        <Patreon />
        Patreon
      </a>
    </Button>
  </Group>
)

const SponsorGroup = (props: {
  sponsors: Sponsor[]
  size?: BoxProps["boxSize"]
}) => {
  const { sponsors, size = "10" } = props
  return (
    <HStack
      wrap="wrap"
      zIndex="5"
      gap="0"
      css={{
        "& > *": {
          "--border-width": "1px",
          borderWidth: "1px",
          borderColor: { _light: "border", _dark: "#001B18" },
          mr: "calc(var(--border-width) * -1)",
          mb: "calc(var(--border-width) * -1)",
          py: "4",
        },
      }}
    >
      {sponsors.map((sponsor) => {
        return (
          <Center asChild key={sponsor.MemberId} px="4" focusRing="outside">
            <a
              href={sponsor.website ?? sponsor.profile}
              target="_blank"
              rel="noopener"
            >
              <SponsorImage
                image={sponsor.image}
                name={sponsor.name}
                size={size}
              />
            </a>
          </Center>
        )
      })}
    </HStack>
  )
}

interface Sponsor {
  MemberId: number
  createdAt: string
  type: string
  role: string
  tier: string
  isActive: boolean
  totalAmountDonated: number
  currency: string
  lastTransactionAt: string
  lastTransactionAmount: number
  profile: string
  name: string
  company: string | null
  description: string | null
  image: string
  email: string | null
  twitter: string | null
  github: string | null
  website: string | null
}

const TierHeading = (props: { tier: string; icon: React.ElementType }) => {
  const { tier, icon: Icon } = props
  return (
    <Flex
      gap="4"
      align="center"
      color={{ _light: "teal.600", _dark: "teal.500" }}
    >
      <Icon />
      <Text fontWeight="medium">{tier}</Text>
    </Flex>
  )
}

const SponsorsList = async () => {
  const response = await fetch(
    "https://opencollective.com/chakra-ui/members/all.json",
  )

  const allSponsors: Sponsor[] = await response.json()
  const companies = allSponsors
    .filter((sponsor) => sponsor.tier && sponsor.type === "ORGANIZATION")
    .sort((a, b) => b.totalAmountDonated - a.totalAmountDonated)

  const platinumSponsors = companies.filter((c) => c.tier.includes("Platinum"))
  const goldSponsors = companies.filter((c) => c.tier.includes("Gold"))

  const silverSponsors = companies.filter((c) => c.tier.includes("Silver"))
  const bronzeSponsors = companies.filter((c) => c.tier.includes("Bronze"))

  return (
    <Stack gap="20">
      <Stack gap="6">
        <TierHeading tier="Gold + Platinum Sponsors" icon={GoldSponsorIcon} />
        <SponsorGroup sponsors={[...platinumSponsors, ...goldSponsors]} />
      </Stack>

      <Stack gap="6">
        <TierHeading tier="Silver + Bronze Sponsors" icon={SilverSponsorIcon} />
        <SponsorGroup
          size="6"
          sponsors={[...silverSponsors, ...bronzeSponsors]}
        />
      </Stack>
    </Stack>
  )
}

export const SponsorSection = () => {
  return (
    <Box py="20" as="section">
      <Container>
        <Blob width="1400px" height="1400px" top="-80%" left="10%" />

        <Stack gap="20" pos="relative">
          <Stack
            align="flex-start"
            justify="space-between"
            direction={{ base: "column", lg: "row" }}
            gap="4"
            width="100%"
          >
            <Stack
              gap={{ base: "3", md: "6" }}
              maxW={{ lg: "xl" }}
              flexShrink="0"
              flex="1"
            >
              <BlitzHeading mb="4">Sponsors</BlitzHeading>
              <HighlightHeading as="h2" query="amazing">
                Sponsored by these amazing companies
              </HighlightHeading>
            </Stack>

            <Stack gap="6" mt="4">
              <Text textStyle="xl" maxW={{ lg: "lg" }}>
                Our maintainers devote their time, effort, and heart to ensure
                Chakra UI keeps getting better.{" "}
                <Span color="fg.muted">
                  Support us by donating to our collective 🙏
                </Span>
              </Text>
              <CallToActions />
            </Stack>
          </Stack>

          <SponsorsList />
        </Stack>
      </Container>
    </Box>
  )
}