Skip to content

Conversation

@cgatian
Copy link
Contributor

@cgatian cgatian commented Jun 5, 2025

Allow components exported as "Parts" to be extracted. In addition it also addresses 2 of the 4 export syntaxes mentioned in #324. I didn't fix all the syntaxes because I didn't want to make too many changes, but certainly can follow-up.

Adds fixes for the following scenarios:


import * as React from 'react';

interface LabelProps {
  /** title description */
  title: string;
}

/** SubComponent description */
const SubComponent = (props: LabelProps) => (
  <div>My Property = {props.title}</div>
);

interface StatelessStaticComponentsProps {
  /** myProp description */
  myProp: string;
}

/** StatelessStaticComponents description */
const StatelessStaticComponents = (props: StatelessStaticComponentsProps) => (
  <div>My Property = {props.myProp}</div>
);

export const Record = {
  Comp1: StatelessStaticComponents,
  Comp2: SubComponent
};

import * as React from 'react';

interface LabelProps {
  /** title description */
  title: string;
}

/** StatelessStaticComponents.Label description */
const SubComponent = (props: LabelProps) => (
  <div>My Property = {props.title}</div>
);

interface StatelessStaticComponentsProps {
  /** myProp description */
  myProp: string;
}

/** StatelessStaticComponents description */
const StatelessStaticComponents = (props: StatelessStaticComponentsProps) => (
  <div>My Property = {props.myProp}</div>
);

export const Components = {
  StatelessStaticComponents,
  SubComponent
};

import * as React from 'react';

interface LabelProps {
  /** title description */
  title: string;
}

/** StatelessStaticComponents.Label description */
const SubComponent = (props: LabelProps) => (
  <div>My Property = {props.title}</div>
);

interface StatelessStaticComponentsProps {
  /** myProp description */
  myProp: string;
}

/** StatelessStaticComponents description */
const StatelessStaticComponents = (props: StatelessStaticComponentsProps) => (
  <div>My Property = {props.myProp}</div>
);

StatelessStaticComponents.Label = SubComponent;

export { StatelessStaticComponents };

import * as React from 'react';

interface LabelProps {
  /** title description */
  title: string;
}

/** StatelessStaticComponents.Label description */
const SubComponent = (props: LabelProps) => (
  <div>My Property = {props.title}</div>
);

interface StatelessStaticComponentsProps {
  /** myProp description */
  myProp: string;
}

/** StatelessStaticComponents description */
function StatelessStaticComponents(props: StatelessStaticComponentsProps) {
  return <div>My Property = {props.myProp}</div>;
}

StatelessStaticComponents.Label = SubComponent;

export { StatelessStaticComponents };

Fixes #324

@cgatian cgatian changed the title Improve subcomponent exports Improve subcomponent and components with "parts" exports Jun 5, 2025
@pvasek pvasek merged commit 4382762 into styleguidist:master Jun 5, 2025
1 check passed
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.

Static subcomponents only work with specific export syntax

2 participants