Skip to content

Commit 093dc20

Browse files
authored
Merge branch 'next-major' into sid/update-changelog-next-major
2 parents 4543712 + 74b2d21 commit 093dc20

File tree

4 files changed

+74
-18
lines changed

4 files changed

+74
-18
lines changed

.github/workflows/release-schedule.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
type: boolean
77
description: 'Run in dry mode. This option will disable creating and closing issues'
88
schedule:
9-
- cron: '30 13 * * MON'
9+
- cron: '30 15 * * MON'
1010

1111
concurrency:
1212
group: ${{ github.workflow }}-${{ github.ref }}

src/drafts/SelectPanel2/SelectPanel.stories.tsx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import {SelectPanel} from './SelectPanel'
33
import {ActionList, ActionMenu, Avatar, Box, Button, Flash} from '../../../src/index'
4-
import {ArrowRightIcon, AlertIcon, EyeIcon, GitBranchIcon, TriangleDownIcon} from '@primer/octicons-react'
4+
import {ArrowRightIcon, AlertIcon, EyeIcon, GitBranchIcon, TriangleDownIcon, TagIcon} from '@primer/octicons-react'
55
import data from './mock-data'
66

77
const getCircle = (color: string) => (
@@ -839,6 +839,39 @@ export const IWithRemoveFilterIcon = () => {
839839
)
840840
}
841841

842+
export const FInstantSelectionVariant = () => {
843+
const [selectedTag, setSelectedTag] = React.useState<string>()
844+
845+
const onSubmit = () => {
846+
if (!selectedTag) return
847+
data.ref = selectedTag // pretending to persist changes
848+
}
849+
850+
const itemsToShow = data.tags
851+
852+
return (
853+
<>
854+
<h1>Instant selection variant</h1>
855+
856+
<SelectPanel title="Choose a tag" selectionVariant="instant" onSubmit={onSubmit} height="medium" defaultOpen>
857+
{/* @ts-ignore todo */}
858+
<SelectPanel.Button leadingIcon={TagIcon}>{selectedTag || 'Choose a tag'}</SelectPanel.Button>
859+
860+
<ActionList>
861+
{itemsToShow.map(tag => (
862+
<ActionList.Item key={tag.id} onSelect={() => setSelectedTag(tag.id)} selected={selectedTag === tag.id}>
863+
{tag.name}
864+
</ActionList.Item>
865+
))}
866+
</ActionList>
867+
<SelectPanel.Footer>
868+
<SelectPanel.SecondaryButton>Edit tags</SelectPanel.SecondaryButton>
869+
</SelectPanel.Footer>
870+
</SelectPanel>
871+
</>
872+
)
873+
}
874+
842875
// ----- Suspense implementation details ----
843876

844877
const cache = new Map()

src/drafts/SelectPanel2/SelectPanel.tsx

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
AnchoredOverlayProps,
1414
Spinner,
1515
Text,
16+
ActionListProps,
1617
} from '../../../src/index'
1718
import {ActionListContainerContext} from '../../../src/ActionList/ActionListContainerContext'
1819
import {useSlots} from '../../hooks/useSlots'
@@ -24,12 +25,14 @@ const SelectPanelContext = React.createContext<{
2425
onClearSelection: undefined | (() => void)
2526
searchQuery: string
2627
setSearchQuery: () => void
28+
selectionVariant: ActionListProps['selectionVariant'] | 'instant'
2729
}>({
2830
title: '',
2931
onCancel: () => {},
3032
onClearSelection: undefined,
3133
searchQuery: '',
3234
setSearchQuery: () => {},
35+
selectionVariant: 'multiple',
3336
})
3437

3538
// @ts-ignore todo
@@ -56,9 +59,9 @@ const SelectPanel = props => {
5659
if (props.open === undefined) setInternalOpen(false)
5760
if (typeof props.onCancel === 'function') props.onCancel()
5861
}
59-
// @ts-ignore todo
60-
const onInternalSubmit = event => {
61-
event.preventDefault()
62+
63+
const onInternalSubmit = (event?: React.SyntheticEvent) => {
64+
event?.preventDefault() // there is no event with selectionVariant=instant
6265
if (props.open === undefined) setInternalOpen(false)
6366
if (typeof props.onSubmit === 'function') props.onSubmit(event)
6467
}
@@ -67,6 +70,10 @@ const SelectPanel = props => {
6770
if (typeof props.onSubmit === 'function') props.onClearSelection()
6871
}
6972

73+
const internalAfterSelect = () => {
74+
if (props.selectionVariant === 'instant') onInternalSubmit()
75+
}
76+
7077
/* Search/Filter */
7178
const [searchQuery, setSearchQuery] = React.useState('')
7279

@@ -96,6 +103,7 @@ const SelectPanel = props => {
96103
searchQuery,
97104
// @ts-ignore todo
98105
setSearchQuery,
106+
selectionVariant: props.selectionVariant,
99107
}}
100108
>
101109
<Box
@@ -126,7 +134,9 @@ const SelectPanel = props => {
126134
container: 'SelectPanel',
127135
listRole: 'listbox',
128136
selectionAttribute: 'aria-selected',
129-
selectionVariant: props.selectionVariant || 'multiple',
137+
selectionVariant:
138+
props.selectionVariant === 'instant' ? 'single' : props.selectionVariant || 'multiple',
139+
afterSelect: internalAfterSelect,
130140
}}
131141
>
132142
{childrenInBody}
@@ -243,7 +253,15 @@ const SelectPanelSearchInput = props => {
243253
SelectPanel.SearchInput = SelectPanelSearchInput
244254

245255
const SelectPanelFooter = ({...props}) => {
246-
const {onCancel} = React.useContext(SelectPanelContext)
256+
const {onCancel, selectionVariant} = React.useContext(SelectPanelContext)
257+
258+
const hidePrimaryActions = selectionVariant === 'instant'
259+
260+
if (hidePrimaryActions && !props.children) {
261+
// nothing to render
262+
// todo: we can inform them the developer footer will render nothing
263+
return null
264+
}
247265

248266
return (
249267
<Box
@@ -255,23 +273,26 @@ const SelectPanelFooter = ({...props}) => {
255273
borderColor: 'border.default',
256274
}}
257275
>
258-
<div>{props.children}</div>
259-
<Box sx={{display: 'flex', gap: 2}}>
260-
<Button size="small" type="button" onClick={() => onCancel()}>
261-
Cancel
262-
</Button>
263-
<Button size="small" type="submit" variant="primary">
264-
Save
265-
</Button>
266-
</Box>
276+
<Box sx={{flexGrow: hidePrimaryActions ? 1 : 0}}>{props.children}</Box>
277+
278+
{hidePrimaryActions ? null : (
279+
<Box sx={{display: 'flex', gap: 2}}>
280+
<Button size="small" type="button" onClick={() => onCancel()}>
281+
Cancel
282+
</Button>
283+
<Button size="small" type="submit" variant="primary">
284+
Save
285+
</Button>
286+
</Box>
287+
)}
267288
</Box>
268289
)
269290
}
270291
SelectPanel.Footer = SelectPanelFooter
271292

272293
// @ts-ignore todo
273294
SelectPanel.SecondaryButton = props => {
274-
return <Button {...props} size="small" type="button" />
295+
return <Button {...props} size="small" type="button" block />
275296
}
276297
// SelectPanel.SecondaryLink = props => {
277298
// return <a {...props}>{props.children}</a>

src/drafts/SelectPanel2/mock-data.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,9 @@ const data = {
922922
{id: 'dependabot/markdownlint-github-0.4.1', name: 'dependabot/markdownlint-github-0.4.1'},
923923
],
924924
tags: [
925-
{id: 'v35.29.0', name: 'v35.29.0', trailingInfo: 'Latest'},
925+
{id: 'v35.31.0', name: 'v35.31.0', trailingInfo: 'Latest'},
926+
{id: 'v35.30.0', name: 'v35.30.0'},
927+
{id: 'v35.29.0', name: 'v35.29.0'},
926928
{id: 'v35.28.0', name: 'v35.28.0'},
927929
{id: 'v35.27.1', name: 'v35.27.1'},
928930
{id: 'v35.27.0', name: 'v35.27.0'},

0 commit comments

Comments
 (0)