Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Expander primitive #252

Merged
merged 1 commit into from
Nov 24, 2021
Merged

feat: add Expander primitive #252

merged 1 commit into from
Nov 24, 2021

Conversation

yeung-wah
Copy link
Contributor

@yeung-wah yeung-wah commented Nov 23, 2021

add Expander primitive

Description of changes:

adding support for expander primitive, both of the primitives would contain children

sample input

{
  "id": "1234-5678-9010",
  "componentType": "Expander",
  "name": "ExpanderPrimitive",
  "properties": {
    "type": {
      "value": "single",
      "type": "String"
    },
    "isCollapsible": {
      "value": true,
      "type": "Boolean"
    }
  },
  "children": [
    {
      "componentType": "ExpanderItem",
      "properties": {
        "title": {
          "value": "title1"
        },
        "value": {
          "value": "ExpanderItem1"
        },
        "children": {
          "value": "ExpanderItem1Content"
        }
      }
    },
    {
      "componentType": "ExpanderItem",
      "properties": {
        "title": {
          "value": "title2"
        },
        "value": {
          "value": "ExpanderItem2"
        },
        "children": {
          "value": "ExpanderItem2Content"
        }
      }
    }
  ]
}

output

/* eslint-disable */
import React from "react";
import { getOverrideProps } from "@aws-amplify/ui-react/internal";
import {
  EscapeHatchProps,
  Expander,
  ExpanderItem,
  ExpanderProps,
} from "@aws-amplify/ui-react";

export type ExpanderPrimitiveProps = React.PropsWithChildren<
  Partial<ExpanderProps> & {
    overrides?: EscapeHatchProps | undefined | null;
  }
>;
export default function ExpanderPrimitive(
  props: ExpanderPrimitiveProps
): React.ReactElement {
  const { overrides: overridesProp, ...rest } = props;
  const overrides = { ...overridesProp };
  return (
    /* @ts-ignore: TS2322 */
    <Expander
      type="single"
      isCollapsible={true}
      {...rest}
      {...getOverrideProps(overrides, "Expander")}
    >
      <ExpanderItem
        title="title1"
        value="ExpanderItem1"
        children="ExpanderItem1Content"
        {...getOverrideProps(overrides, "Expander.ExpanderItem[0]")}
      ></ExpanderItem>
      <ExpanderItem
        title="title2"
        value="ExpanderItem2"
        children="ExpanderItem2Content"
        {...getOverrideProps(overrides, "Expander.ExpanderItem[1]")}
      ></ExpanderItem>
    </Expander>
  );
}

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@dpilch dpilch merged commit 480aa2b into develop Nov 24, 2021
@dpilch dpilch deleted the expander_primitive_develop branch November 24, 2021 16:14
dpilch pushed a commit that referenced this pull request Nov 24, 2021
dpilch pushed a commit that referenced this pull request Nov 24, 2021
dpilch pushed a commit that referenced this pull request Nov 26, 2021
dpilch pushed a commit that referenced this pull request Dec 2, 2021
dpilch pushed a commit that referenced this pull request Dec 3, 2021
dpilch pushed a commit that referenced this pull request Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants