Skip to content

Instantly share code, notes, and snippets.

@omariosouto
Created December 7, 2021 11:05
Show Gist options
  • Save omariosouto/5319b495be4230fa8ebe62543560b231 to your computer and use it in GitHub Desktop.
Save omariosouto/5319b495be4230fa8ebe62543560b231 to your computer and use it in GitHub Desktop.
import FAQScreen from '../src/screens/FAQScreen';
export default FAQScreen;
export async function getStaticProps() {
console.log('Em modo DEV, sempre roda! A cada acesso')
console.log('Roda SOMENTE em build time')
const FAQ_API_URL = 'https://gist.githubusercontent.com/omariosouto/0ceab54bdd8182cbd1a4549d32945c1a/raw/578ad1e8e5296fa048e3e7ff6b317f7497b31ad9/alura-cases-faq.json';
const faq = await fetch(FAQ_API_URL)
.then((respostaDoServidor) => {
return respostaDoServidor.json();
})
.then((resposta) => {
return resposta;
});
return {
props: {
qualquercoisa: 'que eu passar aqui',
faq,
},
};
}
import Footer from '../../components/patterns/Footer';
import Link from '../../components/Link';
import { theme } from '../../theme/theme';
import { Box, Text } from '../../theme/components';
export default function FAQScreen({ faq }) {
return (
<Box
styleSheet={{
backgroundColor: theme.colors.neutral["050"]
}}
>
<Box
as="main"
styleSheet={{
flex: 1,
maxWidth:theme.space.xcontainer_xl,
marginHorizontal: "auto",
paddingHorizontal: {
xs: theme.space.x4,
sm: theme.space.x6,
lg: theme.space.x8,
},
paddingVertical:{
xs: theme.space.x16,
lg: theme.space.x20,
},
}}
>
<Box
styleSheet={{
display: "grid",
gridTemplateColumns: {
lg: "repeat(3,minmax(0,1fr))",
},
gap: {
lg: theme.space.x8,
}
}}
>
<Box>
<Text
as="h2"
styleSheet={{
textVariant:theme.typography.variants.heading2,
color:theme.colors.neutral[900],
}}
>
FAQ: Perguntas Frequentes
</Text>
<Text
as="p"
styleSheet={{
marginTop: theme.space.x4,
textVariant: theme.typography.variants.body1,
color: theme.colors.neutral[500],
}}
>
Não consegue encontrar a resposta que procura? entre em contato com nosso{' '}
<Link
href="mailto:[email protected]"
styleSheet={{
color: theme.colors.primary[400],
hover: {
color: theme.colors.primary[300],
},
}}
>
time de suporte ao consumidor
</Link>
</Text>
<Text
as="p"
styleSheet={{
marginTop: theme.space.x4,
textVariant: theme.typography.variants.body1,
color: theme.colors.neutral[500],
}}
>
<Link
href="/"
styleSheet={{
color: theme.colors.primary[400],
fontWeight: '500',
hover: {
color: theme.colors.primary[300],
},
}}
>
Voltar para home
</Link>
</Text>
</Box>
<Box
styleSheet={{
marginTop: {
xs: theme.space.x12,
lg: theme.space.x0,
},
gridColumn: {
lg: "span 2 / span 2;",
}
}}
>
{faq.length === 0 && (
<Box
styleSheet={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
borderTop: {
xs: `${theme.space.xpx} solid ${theme.colors.neutral["200"]}`,
sm: 'none',
},
paddingTop: {
xs: theme.space.x6,
sm: 0,
},
borderLeft: {
sm: `${theme.space.xpx} solid ${theme.colors.neutral["200"]}`,
},
paddingLeft: {
sm: theme.space.x6,
},
textAlign: "center",
minHeight: theme.space['x1/1']
}}
>
<Text
as="h1"
styleSheet={{
textVariant: theme.typography.variants.heading1,
}}
>
Nada por aqui
</Text>
<Text
as="p"
styleSheet={{
marginTop: theme.space.x1,
textVariant: theme.typography.variants.body1,
color: theme.colors.neutral[500],
}}
>
Talvez ainda não existam dúvidas frequentes.
</Text>
</Box>
)}
<Box as="dl">
{faq.map((faq) => (
<Box
key={faq.question}
styleSheet={{
marginBottom: theme.space.x12,
}}
>
<Text
as="dt"
styleSheet={{
textVariant: theme.typography.variants.heading4,
color: theme.colors.neutral[900],
}}
>
{faq.question}
</Text>
<Text
as="dd"
styleSheet={{
marginTop: theme.space.x2,
textVariant: theme.typography.variants.body1,
color: theme.colors.neutral[500],
}}
>
{faq.answer}
</Text>
</Box>
))}
</Box>
</Box>
</Box>
</Box>
<Footer />
</Box>
)
}
FAQScreen.defaultProps = {
faqs: [],
};
@AngeloCrescencio
Copy link

O FaqScreen perdeu o title, podia revisar com algo mais ou menos assim :

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment