-
Notifications
You must be signed in to change notification settings - Fork 524
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
Add Caret component #58
Conversation
@jonrohan yep, I was thinking that would be possible with |
Check out the differences in the CSS and SVG implementations, which somehow ended up being the exact same number of lines (?!): CSSSVGThe exported component switches between the two via the |
right: `translate(${[0, size]}) rotate(-90)`, | ||
bottom: `translate(${[size, 0]})`, | ||
left: `translate(${[size * 2, size]}) rotate(90)` | ||
}[edge] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that this was easier to read than a switch
statement, but can change it if it seems too clever.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine this way!
I'm down for removing the CSS version and just using SVG which has full browser support. |
}) | ||
|
||
const mapBlockProps = props => classifyBlockProps(map(props)) | ||
const stylize = props => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like something we might want a helper for in props.js
because it's kind of a pain to maintain. I'd like to see something like:
import {passToStyle} from './props'
const stylize = passToStyle([
'width', 'minWidth', 'maxWidth',
'height', 'minHeight', 'maxHeight'
])
const mapBlockProps = props => classifyBlockProps(map(stylize(props))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I was running into this when I was working on the Dropdown stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good to me! Just left a few comments
}) | ||
|
||
const mapBlockProps = props => classifyBlockProps(map(props)) | ||
const stylize = props => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I was running into this when I was working on the Dropdown stuff
right: `translate(${[0, size]}) rotate(-90)`, | ||
bottom: `translate(${[size, 0]})`, | ||
left: `translate(${[size * 2, size]}) rotate(90)` | ||
}[edge] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine this way!
Spoke with the team and @emplums suggested that we use words that people already know like |
The
Caret
component renders a filled and stroked triangle that can be positioned on any edge of its (relatively or absolutely positioned) parent. It looks like this when placed inside aBox
:Props
edge
determines its absolute positioning relative to its container:top
,right
,bottom
(the default), orleft
borderColor
determines the border color; the default is the same light gray applied by theborder
utility classborderWidth
should be self-explanatory; the default is 1 (pixel)fill
determines the fill (background) color; the default is whitealign
determines the alignment along perpendicular edge. In this initial version, it's always centered (align='center'
).Examples
Caveats
There is some serious inline styles voodoo going on here. This should probably be done in SVG rather than with CSS borders.Addendum: as of 5a13341, we now have SVG output by default, with the ability to pass acss
prop that forces it to use CSS border hacks. Should we just do SVG and remove most of the code here?Also in this PR
To support the examples for this, I've also added support for the
position
andshadow
props on the Block component so that we can do relative positioning and box shadows, a booleanmono
prop for Text, andText.propTypes
for validation.