@sproutsocial/seeds-react-accordion 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sproutsocial/seeds-react-accordion",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Seeds React Accordion",
5
5
  "author": "Sprout Social, Inc.",
6
6
  "license": "MIT",
@@ -22,9 +22,9 @@
22
22
  "@sproutsocial/seeds-react-theme": "^3.2.1",
23
23
  "@sproutsocial/seeds-react-system-props": "^3.0.1",
24
24
  "@sproutsocial/seeds-react-box": "1.1.7",
25
- "@sproutsocial/seeds-react-button": "1.3.7",
26
- "@sproutsocial/seeds-react-icon": "2.0.2",
27
- "@sproutsocial/seeds-react-menu": "1.7.1"
25
+ "@sproutsocial/seeds-react-button": "1.3.8",
26
+ "@sproutsocial/seeds-react-icon": "2.0.3",
27
+ "@sproutsocial/seeds-react-menu": "1.7.2"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/react": "^18.0.0",
@@ -8,6 +8,7 @@ import { Box } from "@sproutsocial/seeds-react-box";
8
8
  import { Token } from "@sproutsocial/seeds-react-token";
9
9
  import { Text } from "@sproutsocial/seeds-react-text";
10
10
  import { Icon } from "@sproutsocial/seeds-react-icon";
11
+ import styled from "styled-components";
11
12
 
12
13
  export default {
13
14
  title: "Components/Accordion",
@@ -215,6 +216,13 @@ export const Styleable = {
215
216
  return (
216
217
  <Accordion
217
218
  triggerPosition="left"
219
+ triggerIcon={
220
+ <Icon
221
+ className="triggerIcon"
222
+ name="chevron-down-outline"
223
+ color="red.500"
224
+ />
225
+ }
218
226
  defaultValue={["section-1"]}
219
227
  styled={false}
220
228
  >
@@ -226,6 +234,18 @@ export const Styleable = {
226
234
  color="red.500"
227
235
  fontWeight="bold"
228
236
  fontSize={900}
237
+ relatedActions={[
238
+ {
239
+ iconName: "alarm-clock",
240
+ onClick: () => alert("hello"),
241
+ "aria-label": "Set alarm",
242
+ },
243
+ {
244
+ iconName: "ellipsis-horizontal-outline",
245
+ onClick: () => alert("goodbye"),
246
+ "aria-label": "More options",
247
+ },
248
+ ]}
229
249
  />
230
250
  <AccordionContent bg="blue.300" p={400} typeScale={600}>
231
251
  We don't really know where this goes - and I'm not sure we really
@@ -278,6 +298,53 @@ export const Styleable = {
278
298
  },
279
299
  };
280
300
 
301
+ const StyledTrigger = styled(AccordionTrigger)`
302
+ background-color: blue;
303
+ &:hover {
304
+ background-color: green;
305
+ }
306
+ `;
307
+
308
+ export const UsingStyledTrigger: StoryFn<typeof Accordion> = (args) => {
309
+ return (
310
+ <Accordion {...args}>
311
+ <AccordionItem value="section-1">
312
+ <StyledTrigger
313
+ title="Paint with Bob"
314
+ relatedActions={[
315
+ {
316
+ iconName: "alarm-clock",
317
+ onClick: () => alert("hello"),
318
+ "aria-label": "Set alarm",
319
+ },
320
+ {
321
+ iconName: "ellipsis-horizontal-outline",
322
+ onClick: () => alert("goodbye"),
323
+ "aria-label": "More options",
324
+ },
325
+ ]}
326
+ />
327
+ <AccordionContent>
328
+ <Text.SmallBodyCopy as="p" mb={400}>
329
+ We don't really know where this goes - and I'm not sure we really
330
+ care. Paint anything you want on the canvas. Create your own world.
331
+ We don't need any guidelines or formats. All we need to do is just
332
+ let it flow right out of us. Use absolutely no pressure. Just like
333
+ an angel's wing. In your imagination you can go anywhere you want.
334
+ Every time you practice, you learn more.
335
+ </Text.SmallBodyCopy>
336
+ <Text.SmallBodyCopy as="p">
337
+ A tree needs to be your friend if you're going to paint him. It's
338
+ amazing what you can do with a little love in your heart. If there
339
+ are two big trees, eventually there will be a little tree. Think
340
+ about a cloud. Just float around and be there.
341
+ </Text.SmallBodyCopy>
342
+ </AccordionContent>
343
+ </AccordionItem>
344
+ </Accordion>
345
+ );
346
+ };
347
+
281
348
  export const Single = {
282
349
  args: {
283
350
  defaultValue: ["section-1"],
@@ -99,6 +99,8 @@ export const AccordionTrigger = ({
99
99
  }).filter(([_, value]) => value != null)
100
100
  );
101
101
 
102
+ const shouldRenderActionsBlock = Boolean(overflowMenu || validatedActions);
103
+
102
104
  // Render overflow menu from config
103
105
  const renderedOverflowMenu = overflowMenu && (
104
106
  <ActionMenu
@@ -107,7 +109,11 @@ export const AccordionTrigger = ({
107
109
  aria-label={overflowMenu["aria-label"]}
108
110
  appearance="unstyled"
109
111
  >
110
- <Icon name="ellipsis-horizontal-outline" aria-hidden="true" />
112
+ <Icon
113
+ name="ellipsis-horizontal-outline"
114
+ aria-hidden="true"
115
+ color={color}
116
+ />
111
117
  </MenuToggleButton>
112
118
  }
113
119
  >
@@ -123,8 +129,13 @@ export const AccordionTrigger = ({
123
129
  {...menuItemProps}
124
130
  >
125
131
  {iconName ? (
126
- <Box display="flex" alignItems="center" gap="300">
127
- <Icon name={iconName} />
132
+ <Box
133
+ display="flex"
134
+ alignItems="center"
135
+ gap="300"
136
+ color={color}
137
+ >
138
+ <Icon name={iconName} color={color} />
128
139
  {children}
129
140
  </Box>
130
141
  ) : (
@@ -148,14 +159,14 @@ export const AccordionTrigger = ({
148
159
  onClick={action.onClick}
149
160
  aria-label={action["aria-label"]}
150
161
  >
151
- <Icon name={action.iconName} aria-hidden="true" />
162
+ <Icon name={action.iconName} color={color} aria-hidden="true" />
152
163
  </Button>
153
164
  ))}
154
165
  </Box>
155
166
  );
156
167
 
157
168
  return (
158
- <TriggerContainer data-styled={styled} {...triggerProps}>
169
+ <TriggerContainer data-styled={styled} $styled={styled} {...triggerProps}>
159
170
  <StyledRadixAccordionTrigger data-styled={styled} {...spacingProps}>
160
171
  {triggerPosition === "right" ? (
161
172
  <StyledAccordionArea>
@@ -181,10 +192,12 @@ export const AccordionTrigger = ({
181
192
  </StyledAccordionArea>
182
193
  )}
183
194
  </StyledRadixAccordionTrigger>
184
- <Box mr={300} display="flex">
185
- {renderedOverflowMenu}
186
- {renderedRelatedActions}
187
- </Box>
195
+ {shouldRenderActionsBlock && (
196
+ <Box mr={300} display="flex">
197
+ {renderedOverflowMenu}
198
+ {renderedRelatedActions}
199
+ </Box>
200
+ )}
188
201
  </TriggerContainer>
189
202
  );
190
203
  };
package/src/styles.ts CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  LAYOUT,
9
9
  TYPOGRAPHY,
10
10
  } from "@sproutsocial/seeds-react-system-props";
11
+ import { focusRing } from "@sproutsocial/seeds-react-mixins";
11
12
  import { type TypeAccordionSystemProps } from "./AccordionTypes";
12
13
 
13
14
  interface StyledAccordionProps extends TypeAccordionSystemProps {
@@ -51,7 +52,6 @@ export const StyledRadixAccordionTrigger = styled(
51
52
  ${({ theme }) => theme.typography[200]};
52
53
 
53
54
  .triggerIcon {
54
- color: ${({ theme }) => theme.colors.icon.base};
55
55
  transition: transform 300ms ease-in-out;
56
56
  }
57
57
 
@@ -65,6 +65,10 @@ export const StyledRadixAccordionTrigger = styled(
65
65
  padding: ${({ theme }) => theme.space[400]};
66
66
  }
67
67
 
68
+ &:focus {
69
+ ${focusRing}
70
+ }
71
+
68
72
  ${COMMON}
69
73
  `;
70
74
 
@@ -138,15 +142,14 @@ export const TriggerContainer = styled.div<StyledAccordionProps>`
138
142
  display: flex;
139
143
  align-items: center;
140
144
 
141
- &[data-styled="true"] {
142
- border-top: ${({ theme }) =>
143
- `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};
144
- border-left: ${({ theme }) =>
145
- `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};
146
- border-right: ${({ theme }) =>
147
- `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};
148
- background: ${({ theme }) => theme.colors.container.background.base};
149
- }
145
+ ${({ $styled, theme }) =>
146
+ $styled &&
147
+ `
148
+ border-top: ${theme.borderWidths[500]} solid ${theme.colors.container.border.base};
149
+ border-left: ${theme.borderWidths[500]} solid ${theme.colors.container.border.base};
150
+ border-right: ${theme.borderWidths[500]} solid ${theme.colors.container.border.base};
151
+ background: ${theme.colors.container.background.base};
152
+ `}
150
153
 
151
154
  .accordion-item[data-state="open"] &[data-styled="true"] {
152
155
  border-bottom: ${({ theme }) =>