返回 marp
Description.tsx
根目录 / website / components / top / Description.tsx
1 import { ChevronDownIcon } from '@primer/octicons-react'
2 import classNames from 'classnames'
3 import { useState } from 'react'
4 import { Button } from 'components/Button'
5 import { CodeBlock } from 'components/CodeBlock'
6 import { Marp, RenderedMarp } from 'components/Marp'
7
8 export type DescriptionProps = {
9 example: RenderedMarp
10 }
11
12 export const Description = ({ example }: DescriptionProps) => {
13 const [showExample, setShowExample] = useState(false)
14
15 return (
16 <section className="container mx-auto py-16">
17 <h2 className="text-gradient mx-auto w-5/6 text-center text-3xl font-bold md:text-4xl">
18 Create beautiful slide decks using an intuitive Markdown experience
19 </h2>
20 <p className="mx-auto mt-8 w-5/6 md:text-lg lg:w-2/3">
21 Marp (also known as the Markdown Presentation Ecosystem) provides an
22 intuitive experience for creating beautiful slide decks. You only have
23 to focus on writing your story in a Markdown document.
24 </p>
25 <figure className="m-8 mb-0 text-center">
26 <Marp
27 rendered={example}
28 page={1}
29 className="inline-block w-full max-w-sm"
30 />
31 <Marp
32 rendered={example}
33 page={2}
34 className="mt-5 inline-block w-full max-w-sm lg:ml-5 lg:mt-0"
35 />
36 <figcaption className="mt-5 text-sm text-gray-700">
37 The slides above are from generated directly from{' '}
38 <a href="https://github.com/marp-team/marp-core">Marp Core</a>
39 </figcaption>
40 </figure>
41 <p className="show-example-section">
42 <Button
43 className="show-example-btn"
44 onClick={() => setShowExample((v) => !v)}
45 aria-expanded={showExample}
46 >
47 {showExample ? 'Hide' : 'Show'} Markdown example...
48 <ChevronDownIcon
49 className={classNames(
50 'show-example-btn-chevron',
51 showExample && 'show'
52 )}
53 />
54 </Button>
55 </p>
56 <div
57 aria-hidden={!showExample}
58 className="overflow-hidden transition-all duration-300"
59 style={{ maxHeight: showExample ? '1000px' : '0' }}
60 >
61 <CodeBlock
62 language="markdown"
63 lineNumber
64 className="mx-auto mt-5 w-5/6 xl:w-2/3"
65 copyButton={showExample}
66 >
67 {example.markdown}
68 </CodeBlock>
69 </div>
70 <style jsx>{`
71 .show-example-section {
72 @apply mx-auto mt-8 w-5/6 text-center;
73 }
74 .show-example-section :global(.show-example-btn) {
75 @apply text-sm;
76 }
77 .show-example-section :global(.show-example-btn-chevron) {
78 @apply ml-1 h-4 w-4 transform transition-transform duration-300 md:-my-1 md:h-6 md:w-6;
79 }
80 .show-example-section :global(.show-example-btn-chevron:not(.show)) {
81 @apply relative;
82
83 top: -1px;
84 }
85 .show-example-section :global(.show-example-btn-chevron.show) {
86 @apply -rotate-180;
87 }
88
89 @screen md {
90 .show-example-section :global(.show-example-btn-chevron:not(.show)) {
91 top: -2px;
92 }
93 }
94 `}</style>
95 </section>
96 )
97 }
98
98 lines Plain Text