-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored __docs__/components/feature
- Loading branch information
Showing
12 changed files
with
169 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from "react"; | ||
|
||
import { Feature } from "./feature"; | ||
|
||
export type AsDocProps = { | ||
asType: string; | ||
}; | ||
|
||
export const AsDoc: React.FC<AsDocProps> = ({ asType }) => ( | ||
<Feature | ||
primaryName="as" | ||
primaryColor="light" | ||
secondaryName={asType} | ||
secondaryColor="warning" | ||
url="/architecture/inversion-of-control" | ||
/> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from "react"; | ||
|
||
import { AsDoc, AsDocProps } from "./as-doc"; | ||
import { CustomizeFeature, CustomizeFeatureProps } from "./customize-feature"; | ||
import { DocFeature, DocFeatureProps } from "./doc-feature"; | ||
import { Feature } from "./feature"; | ||
|
||
export type ComponentFeaturesProps = AsDocProps & | ||
DocFeatureProps & | ||
CustomizeFeatureProps; | ||
|
||
export const ComponentFeatures: React.FC<ComponentFeaturesProps> = ({ | ||
asType, | ||
docPath, | ||
customize, | ||
}) => ( | ||
<Feature.Group> | ||
<AsDoc asType={asType} /> | ||
<CustomizeFeature customize={customize} /> | ||
<DocFeature docPath={docPath} /> | ||
</Feature.Group> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from "react"; | ||
|
||
import { Feature } from "./feature"; | ||
|
||
export type CustomizeFeatureProps = { | ||
customize?: boolean; | ||
}; | ||
|
||
export const CustomizeFeature: React.FC<CustomizeFeatureProps> = ({ | ||
customize, | ||
}) => { | ||
const name = customize === true ? "yes" : "no"; | ||
const color = customize === true ? "success" : "danger"; | ||
|
||
return ( | ||
<Feature | ||
primaryName="customize" | ||
primaryColor="light" | ||
secondaryName={name} | ||
secondaryColor={color} | ||
url="/architecture/customize" | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from "react"; | ||
|
||
import { Feature } from "./feature"; | ||
|
||
export type DocFeatureProps = { | ||
docPath?: string; | ||
}; | ||
|
||
export const DocFeature: React.FC<DocFeatureProps> = ({ docPath }) => { | ||
const url = | ||
docPath !== undefined | ||
? `https://bulma.io/documentation${docPath}` | ||
: undefined; | ||
const secondaryName = docPath !== undefined ? "Bulma" : "n/a"; | ||
const secondaryColor = docPath !== undefined ? "primary" : "dark"; | ||
|
||
return ( | ||
<Feature | ||
primaryName="docs" | ||
primaryColor="light" | ||
secondaryName={secondaryName} | ||
secondaryColor={secondaryColor} | ||
url={url} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from "react"; | ||
|
||
import { Field } from "src/elements"; | ||
|
||
export type FeatureGroupProps = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
export const FeatureGroup: React.FC<FeatureGroupProps> = ({ children }) => ( | ||
<Field kind="group" children={children} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Link } from "docz"; | ||
import React from "react"; | ||
|
||
import { Variables } from "src/base/helpers/variables"; | ||
import { Control, Tag } from "src/elements"; | ||
|
||
import { FeatureGroup } from "./feature-group"; | ||
|
||
export type FeatureProps = { | ||
primaryName: string; | ||
primaryColor: Variables["colors"]; | ||
secondaryName: string; | ||
secondaryColor: Variables["colors"]; | ||
url?: string; | ||
}; | ||
|
||
export const Feature = Object.assign( | ||
({ | ||
primaryName, | ||
primaryColor, | ||
secondaryName, | ||
secondaryColor, | ||
url, | ||
}: FeatureProps) => { | ||
const tagGroupProps = | ||
url === undefined | ||
? {} | ||
: /^\/[a-z]/.test(url) // Local path, e.g. '/somewhere' | ||
? { as: Link, to: url } | ||
: { | ||
as: "a" as keyof JSX.IntrinsicElements, | ||
href: url, | ||
target: "_blank", | ||
}; | ||
|
||
return ( | ||
<Control> | ||
<Tag.Group gapless {...tagGroupProps}> | ||
<Tag color={primaryColor}>{primaryName}</Tag> | ||
<Tag color={secondaryColor}>{secondaryName}</Tag> | ||
</Tag.Group> | ||
</Control> | ||
); | ||
}, | ||
{ Group: FeatureGroup }, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export { AsDoc } from "./as-doc"; | ||
export { ComponentFeatures } from "./component-features"; | ||
export { CustomizeFeature } from "./customize-feature"; | ||
export { DocFeature } from "./doc-feature"; | ||
export { Feature } from "./feature"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
export { | ||
ComponentDoc, | ||
ForwardRefAsExoticComponentDoc, | ||
asDoc, | ||
refDoc, | ||
} from "./component-doc"; | ||
export { ComponentFeatures } from "./feature"; | ||
export * from "./component-doc"; | ||
export * from "./feature"; | ||
export { Frame } from "./frame"; | ||
export { OptionBlock } from "./option-block"; | ||
export { SimplePropsTable } from "./simple-props-table"; | ||
export * from "./simple-props-table"; | ||
export { mapEnumerable } from "./utils"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters