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(packages/sui-studio): allow packages store its component on any file and gets its documentation #1546

Draft
wants to merge 61 commits into
base: master
Choose a base branch
from

Conversation

andresin87
Copy link
Member

@andresin87 andresin87 commented Nov 21, 2022

Description

This PR is related to #1518

It allows component packages to follow the structure

// under components/[categoryName]/[componentName]
// - index.js
// - [Component].js (this file can be placed anywhere and can be imported through any file recursively) and contains the default exported Component, which will be documented in the sui-studio API tab

index.js

//  index.js *************************************************************
import [Component] from './[Component].js'
import Foo {bar1, bar2 as fooBar2} from './Foo.js'

export {
  Foo
  bar1,
  fooBar2 as bar3
}
export default [Component]

[Component].js

// - [Component].js ****************************************************

// Tested using
// VariableDeclaration
const Component = ({as: As, children, ...props}) => <As {...props}>{children}</As>

// FunctionDeclaration
function Component({as: As, children, ...props}) { return <As {...props}>{children}</As> }

// ClassDeclaration
class Component {
	constructor(props) {
		super(props)
	}
	render() {
		const {as: As, children, ...props} = this.props
		return  <As {...props}>{children}</As>
	}
}

// ExportNamedDeclaration
export const Component = ({as: As, children, ...props}) => <As {...props}>{children}</As>

// ExportDefaultDeclaration
export default function Component({as: As, children, ...props}) { return <As {...props}>{children}</As> }

This approach copy all js files to the public dir to get the proper documentation on a JSON, and then it removes all of them to do NOT impact to the next js file rate MAX_LIMIT_UPLOADS=5000

Related Issue

#1518

Example

Test it using @s-ui/[email protected] in your own vertical studios

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

5 participants