Skip to content

Commit

Permalink
[MP-NULL] Update Section example (#4680)
Browse files Browse the repository at this point in the history
  • Loading branch information
sashuk authored Feb 25, 2025
1 parent a6c8f43 commit 73ebf46
Showing 1 changed file with 12 additions and 26 deletions.
38 changes: 12 additions & 26 deletions packages/base/Section/src/Section/story/Controlled.example.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,28 @@
import React, { useState } from 'react'
import { Button, Container, Section } from '@toptal/picasso'
import { Button, Container, Section, Typography } from '@toptal/picasso'
import { SPACING_4 } from '@toptal/picasso-utils'

const FIRST_SECTION_ID = 0
const SECOND_SECTION_ID = 1

const Example = () => {
const [expandedSection, setExpandedSection] = useState(FIRST_SECTION_ID)
const [sectionIsOpened, setSectionIsOpened] = useState(false)

return (
<>
<Section
collapsible
onToggle={collapsed =>
setExpandedSection(collapsed ? SECOND_SECTION_ID : FIRST_SECTION_ID)
}
variant='bordered'
title='First section'
collapsed={expandedSection !== FIRST_SECTION_ID}
>
<p>First section content</p>
<Button onClick={() => setExpandedSection(SECOND_SECTION_ID)}>
Go to second section
<Container>
<Button onClick={() => setSectionIsOpened(!sectionIsOpened)}>
Toggle section
</Button>
</Section>
</Container>
<Container top={SPACING_4}>
<Section
collapsible
onToggle={collapsed =>
setExpandedSection(collapsed ? FIRST_SECTION_ID : SECOND_SECTION_ID)
}
onToggle={collapsed => setSectionIsOpened(collapsed ? false : true)}
variant='bordered'
title='Second section'
collapsed={expandedSection !== SECOND_SECTION_ID}
title='First section'
collapsed={!sectionIsOpened}
>
<p>Second section content</p>
<Button onClick={() => setExpandedSection(FIRST_SECTION_ID)}>
Go to first section
<Typography>First section content</Typography>
<Button onClick={() => setSectionIsOpened(false)}>
Close section
</Button>
</Section>
</Container>
Expand Down

0 comments on commit 73ebf46

Please sign in to comment.