Skip to content

Commit c2a66ec

Browse files
Update SelectPanel.examples stories to no longer use styled-components (#6476)
Co-authored-by: primer[bot] <119360173+primer[bot]@users.noreply.github.com>
1 parent 3daa5d3 commit c2a66ec

File tree

2 files changed

+36
-31
lines changed

2 files changed

+36
-31
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* CSS Module for SelectPanel examples stories */
2+
3+
.ColorCircle {
4+
width: 14px;
5+
height: 14px;
6+
border-radius: var(--borderRadius-full);
7+
margin: auto;
8+
border-width: var(--borderWidth-thin);
9+
border-style: solid;
10+
}
11+
12+
.CustomActionListItem {
13+
margin-left: var(--base-size-8);
14+
margin-right: var(--base-size-8);
15+
}
16+
17+
.CustomActionListItem[data-is-active-descendant='activated-directly'] {
18+
background-color: transparent;
19+
outline: 2px solid var(--focus-outlineColor, var(--color-accent-emphasis));
20+
outline-offset: -2px;
21+
}
22+
23+
.TruncatedText {
24+
overflow: hidden;
25+
white-space: nowrap;
26+
text-overflow: ellipsis;
27+
}

packages/react/src/SelectPanel/SelectPanel.examples.stories.tsx

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, {useState, useMemo} from 'react'
2-
import Box from '../Box'
32
import type {Meta} from '@storybook/react-vite'
43
import {Button} from '../Button'
54
import type {ItemInput} from '../deprecated/ActionList/List'
@@ -10,6 +9,7 @@ import {ActionList} from '../deprecated/ActionList'
109
import FormControl from '../FormControl'
1110
import {Stack} from '../Stack'
1211
import {Dialog} from '../experimental'
12+
import styles from './SelectPanel.examples.stories.module.css'
1313

1414
const meta: Meta<typeof SelectPanel> = {
1515
title: 'Components/SelectPanel/Examples',
@@ -29,15 +29,12 @@ const NoResultsMessage = (filter: string): {variant: 'empty'; title: string; bod
2929
function getColorCircle(color: string) {
3030
return function () {
3131
return (
32-
<Box
33-
bg={color}
34-
borderColor={color}
35-
width={14}
36-
height={14}
37-
borderRadius={10}
38-
margin="auto"
39-
borderWidth="1px"
40-
borderStyle="solid"
32+
<div
33+
className={styles.ColorCircle}
34+
style={{
35+
backgroundColor: color,
36+
borderColor: color,
37+
}}
4138
/>
4239
)
4340
}
@@ -300,28 +297,9 @@ export const CustomItemRenderer = () => {
300297
onFilterChange={setFilter}
301298
overlayProps={{width: 'medium'}}
302299
renderItem={item => (
303-
<ActionList.Item
304-
{...item}
305-
text={undefined}
306-
sx={{
307-
mx: 2,
308-
'&[data-is-active-descendant="activated-directly"]': {
309-
backgroundColor: 'transparent',
310-
outline: '2px solid var(--focus-outlineColor, var(--color-accent-emphasis))',
311-
outlineOffset: '-2px',
312-
},
313-
}}
314-
>
300+
<ActionList.Item {...item} text={undefined} className={styles.CustomActionListItem}>
315301
{' '}
316-
<Box
317-
sx={{
318-
overflow: 'hidden',
319-
whiteSpace: 'nowrap',
320-
textOverflow: 'ellipsis',
321-
}}
322-
>
323-
{item.text}
324-
</Box>
302+
<div className={styles.TruncatedText}>{item.text}</div>
325303
</ActionList.Item>
326304
)}
327305
message={filteredItems.length === 0 ? NoResultsMessage(filter) : undefined}

0 commit comments

Comments
 (0)