[react] feat: Added docs for components/Logo
This commit is contained in:
parent
b011c626b0
commit
3364be6052
4 changed files with 84 additions and 10 deletions
|
@ -1,17 +1,18 @@
|
|||
import React from 'react'
|
||||
import { logoPath } from '@freesewing/config'
|
||||
|
||||
/*
|
||||
/**
|
||||
* The FreeSewing logo, aka Skully, as a React component
|
||||
*
|
||||
* @params {object} props - All React props
|
||||
* @params {string} className - Custom CSS classes to apply
|
||||
* @params {string} theme - The theme, light or dark. Although by default this component will auto-adapt by using currentColor
|
||||
* @params {number} stroke - Set this to also stroke the logo
|
||||
* @component
|
||||
* @param {object} props - All component props
|
||||
* @param {string} [props.className = "tw:w-20 tw:h-20"] - Custom CSS classes to apply
|
||||
* @param {string} [props.stroke = undefined] - Set this explicitly to use a different stroke color
|
||||
* @returns {JSX.Element}
|
||||
*/
|
||||
export const FreeSewingLogo = ({ className = 'w-20 h-20', theme = 'light', stroke = false }) => {
|
||||
export const FreeSewingLogo = ({ className = 'tw:w-20 tw:h-20', stroke }) => {
|
||||
const svgProps = {}
|
||||
const strokes = { light: '#000', darf: '#fff' }
|
||||
const strokes = { dark: '#000', light: 'var(--p)' }
|
||||
|
||||
return (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="1 0 25 25" className={className}>
|
||||
|
@ -21,10 +22,12 @@ export const FreeSewingLogo = ({ className = 'w-20 h-20', theme = 'light', strok
|
|||
<use
|
||||
xlinkHref="#react-logo"
|
||||
fill="none"
|
||||
stroke={stroke || strokes[theme]}
|
||||
strokeWidth="0.5"
|
||||
style={{ stroke: stroke ? stroke : 'var(--color-base-100)'}}
|
||||
/>
|
||||
<use xlinkHref="#react-logo" fill="currentColor" stroke="none" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,3 +20,4 @@ jsdoc -c jsdoc.json components/KeyVal/* > ../../sites/dev/prebuild/jsdoc/react/c
|
|||
jsdoc -c jsdoc.json components/Layout/* > ../../sites/dev/prebuild/jsdoc/react/components/layout.json
|
||||
jsdoc -c jsdoc.json components/LineDrawing/* > ../../sites/dev/prebuild/jsdoc/react/components/linedrawing.json
|
||||
jsdoc -c jsdoc.json components/Link/* > ../../sites/dev/prebuild/jsdoc/react/components/link.json
|
||||
jsdoc -c jsdoc.json components/Logo/* > ../../sites/dev/prebuild/jsdoc/react/components/logo.json
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
import React from 'react'
|
||||
import { FreeSewingLogo } from '@freesewing/react/components/Logo'
|
||||
import { Highlight } from '@freesewing/react/components/Highlight'
|
||||
|
||||
export const FreeSewingLogoExample = () => (
|
||||
<>
|
||||
<div className="tw:flex tw:flex-row tw:flex-wrap tw:gap-4">
|
||||
<div>
|
||||
<h4>Default</h4>
|
||||
<div className="tw:flex tw:flex-row tw:flex-wrap tw:gap-4">
|
||||
<FreeSewingLogo />
|
||||
<div style={{
|
||||
background: `repeating-linear-gradient(45deg, #000 0px, #000 10px, #FFF 10px, #FFF 20px)`
|
||||
}}>
|
||||
<FreeSewingLogo />
|
||||
</div>
|
||||
</div>
|
||||
<small className="tw:block tw:mx-auto tw:leading-4 tw:text-center">the busy background<br />reveals the stroke</small>
|
||||
</div>
|
||||
<div className="tw:grow"><Highlight language="JSX">{`<FreeSewingLogo />`}</Highlight></div>
|
||||
</div>
|
||||
<div className="tw:flex tw:flex-row tw:flex-wrap tw:gap-4">
|
||||
<div>
|
||||
<h4>Different color/size</h4>
|
||||
<FreeSewingLogo className="tw:w-36 tw:h-36 tw:text-primary" />
|
||||
</div>
|
||||
<div className="tw:grow">
|
||||
<Highlight language="JSX">{`<FreeSewingLogo className="tw:w-36 tw:h-36 tw:text-primary" />`}</Highlight>
|
||||
</div>
|
||||
</div>
|
||||
<div className="tw:flex tw:flex-row tw:flex-wrap tw:gap-4">
|
||||
<div>
|
||||
<h4>Different stroke</h4>
|
||||
<FreeSewingLogo stroke="red"/>
|
||||
</div>
|
||||
<div className="tw:grow">
|
||||
<Highlight language="JSX">{`<FreeSewingLogo stroke="red" />`}</Highlight>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
|
@ -1,7 +1,36 @@
|
|||
---
|
||||
title: Logo
|
||||
---
|
||||
import { DocusaurusDoc } from '@freesewing/react/components/Docusaurus'
|
||||
import { ComponentDocs } from '@site/src/components/component-docs.js'
|
||||
import * as jsdoc from '@site/prebuild/jsdoc/components.logo.mjs'
|
||||
import { FreeSewingLogoExample } from './_examples.js'
|
||||
|
||||
:::note
|
||||
This page is yet to be created
|
||||
|
||||
<DocusaurusDoc>
|
||||
|
||||
The __Logo__ component family provides the following components:
|
||||
|
||||
- [FreeSewingLogo](#freesewinglogo)
|
||||
|
||||
## FreeSewingLogo
|
||||
|
||||
:::tip Understanding the colors of the logo
|
||||
The logo will always be filled with `currentColor` which is a specific keyword
|
||||
that will be substituted with whatever the current text color is.
|
||||
|
||||
Furthermore, two logos will be stacked on top of each other.
|
||||
The one filled with `currentColor` sits on top, and below it sits one that is
|
||||
not filled, but stroked with `var(--background-base-100)`.
|
||||
|
||||
This ensures that if the logo is placed on a background with low contrast, it
|
||||
stands out On the default background, the stroked version will be the same
|
||||
color, so it will be invisible.
|
||||
|
||||
You can also set an explicit stroke color with the `stroke` prop, or control
|
||||
`currentColor` by setting the `className` prop.
|
||||
:::
|
||||
<ComponentDocs docs={jsdoc.jsdocFreeSewingLogo} example={FreeSewingLogoExample} />
|
||||
|
||||
</DocusaurusDoc>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue