-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- With examples using `pattern`s, allow building the URL from its component parts, including the query string. - Provide a button to copy the link, with an animation. To enable this for other badges, convert them to use a `pattern`: #1961.
- Loading branch information
1 parent
da12f00
commit 6c2b040
Showing
16 changed files
with
1,288 additions
and
79 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 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,48 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import styled from 'styled-components' | ||
|
||
const BuilderOuterContainer = styled.div` | ||
margin-top: 10px; | ||
margin-bottom: 10px; | ||
` | ||
|
||
// The inner container is inline-block so that its width matches its columns. | ||
const BuilderInnerContainer = styled.div` | ||
display: inline-block; | ||
padding: 11px 14px 10px; | ||
border-radius: 4px; | ||
background: #eef; | ||
` | ||
|
||
const BuilderContainer = ({ children }) => ( | ||
<BuilderOuterContainer> | ||
<BuilderInnerContainer>{children}</BuilderInnerContainer> | ||
</BuilderOuterContainer> | ||
) | ||
BuilderContainer.propTypes = { | ||
children: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.node), | ||
PropTypes.node, | ||
]), | ||
} | ||
|
||
const labelFont = ` | ||
font-family: system-ui; | ||
font-size: 11px; | ||
text-transform: lowercase; | ||
` | ||
|
||
const BuilderLabel = styled.label` | ||
${labelFont} | ||
` | ||
|
||
const BuilderCaption = styled.span` | ||
${labelFont} | ||
color: #999; | ||
` | ||
|
||
export { BuilderContainer, BuilderLabel, BuilderCaption } |
74 changes: 74 additions & 0 deletions
74
frontend/components/markup-modal/copied-content-indicator.js
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,74 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import posed from 'react-pose' | ||
import styled from 'styled-components' | ||
|
||
const ContentAnchor = styled.span` | ||
position: relative; | ||
display: inline-block; | ||
` | ||
|
||
// 100vw allows providing styled content which is wider than its container. | ||
const ContentContainer = styled.span` | ||
width: 100vw; | ||
position: absolute; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
will-change: opacity, top; | ||
pointer-events: none; | ||
` | ||
|
||
const PosedContentContainer = posed(ContentContainer)({ | ||
hidden: { opacity: 0, transition: { duration: 100 } }, | ||
effectStart: { top: '-10px', opacity: 1.0, transition: { duration: 0 } }, | ||
effectEnd: { top: '-75px', opacity: 0.5 }, | ||
}) | ||
|
||
// When `trigger()` is called, render copied content that floats up, then | ||
// disappears. | ||
export default class CopiedContentIndicator extends React.Component { | ||
state = { | ||
pose: 'hidden', | ||
} | ||
|
||
trigger() { | ||
this.setState({ pose: 'effectStart' }) | ||
} | ||
|
||
handlePoseComplete = () => { | ||
const { pose } = this.state | ||
if (pose === 'effectStart') { | ||
this.setState({ pose: 'effectEnd' }) | ||
} else { | ||
this.setState({ pose: 'hidden' }) | ||
} | ||
} | ||
|
||
render() { | ||
const { pose } = this.state | ||
return ( | ||
<ContentAnchor> | ||
<PosedContentContainer | ||
pose={pose} | ||
onPoseComplete={this.handlePoseComplete} | ||
> | ||
{this.props.copiedContent} | ||
</PosedContentContainer> | ||
{this.props.children} | ||
</ContentAnchor> | ||
) | ||
} | ||
} | ||
CopiedContentIndicator.propTypes = { | ||
copiedContent: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.node), | ||
PropTypes.node, | ||
]), | ||
children: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.node), | ||
PropTypes.node, | ||
]), | ||
} |
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
Oops, something went wrong.