@sproutsocial/seeds-react-accordion 0.2.1 → 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.1",
3
+ "version": "0.2.2",
4
4
  "description": "Seeds React Accordion",
5
5
  "author": "Sprout Social, Inc.",
6
6
  "license": "MIT",
@@ -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",
@@ -297,6 +298,53 @@ export const Styleable = {
297
298
  },
298
299
  };
299
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
+
300
348
  export const Single = {
301
349
  args: {
302
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
@@ -164,7 +166,7 @@ export const AccordionTrigger = ({
164
166
  );
165
167
 
166
168
  return (
167
- <TriggerContainer data-styled={styled} {...triggerProps}>
169
+ <TriggerContainer data-styled={styled} $styled={styled} {...triggerProps}>
168
170
  <StyledRadixAccordionTrigger data-styled={styled} {...spacingProps}>
169
171
  {triggerPosition === "right" ? (
170
172
  <StyledAccordionArea>
@@ -190,10 +192,12 @@ export const AccordionTrigger = ({
190
192
  </StyledAccordionArea>
191
193
  )}
192
194
  </StyledRadixAccordionTrigger>
193
- <Box mr={300} display="flex">
194
- {renderedOverflowMenu}
195
- {renderedRelatedActions}
196
- </Box>
195
+ {shouldRenderActionsBlock && (
196
+ <Box mr={300} display="flex">
197
+ {renderedOverflowMenu}
198
+ {renderedRelatedActions}
199
+ </Box>
200
+ )}
197
201
  </TriggerContainer>
198
202
  );
199
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 {
@@ -64,6 +65,10 @@ export const StyledRadixAccordionTrigger = styled(
64
65
  padding: ${({ theme }) => theme.space[400]};
65
66
  }
66
67
 
68
+ &:focus {
69
+ ${focusRing}
70
+ }
71
+
67
72
  ${COMMON}
68
73
  `;
69
74
 
@@ -137,15 +142,14 @@ export const TriggerContainer = styled.div<StyledAccordionProps>`
137
142
  display: flex;
138
143
  align-items: center;
139
144
 
140
- &[data-styled="true"] {
141
- border-top: ${({ theme }) =>
142
- `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};
143
- border-left: ${({ theme }) =>
144
- `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};
145
- border-right: ${({ theme }) =>
146
- `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};
147
- background: ${({ theme }) => theme.colors.container.background.base};
148
- }
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
+ `}
149
153
 
150
154
  .accordion-item[data-state="open"] &[data-styled="true"] {
151
155
  border-bottom: ${({ theme }) =>