forked from TurboWarp/scratch-gui
-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae15f36
commit e962b39
Showing
12 changed files
with
340 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import bindAll from 'lodash.bindall'; | ||
import styles from './fonts-modal.css'; | ||
|
||
class FontDropdownItem extends React.Component { | ||
constructor (props) { | ||
super(props); | ||
bindAll(this, [ | ||
'handleSelect' | ||
]); | ||
} | ||
|
||
handleSelect () { | ||
this.props.onSelect(this.props.family); | ||
} | ||
|
||
render () { | ||
return ( | ||
<div | ||
className={styles.fontDropdownItem} | ||
title={this.props.family} | ||
style={{ | ||
fontFamily: this.props.family | ||
}} | ||
onMouseDown={this.handleSelect} | ||
> | ||
{this.props.family} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
FontDropdownItem.propTypes = { | ||
family: PropTypes.string.isRequired, | ||
onSelect: PropTypes.func.isRequired | ||
}; | ||
|
||
export default FontDropdownItem; |
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,20 @@ | ||
@import "../../css/colors.css"; | ||
|
||
.code { | ||
display: block; | ||
width: 100%; | ||
max-width: 100%; | ||
min-width: 100%; | ||
height: 5rem; | ||
min-height: 3rem; | ||
border: 1px solid $ui-black-transparent; | ||
border-radius: 0.25rem; | ||
padding: 0.25rem; | ||
font-size: 0.875rem; | ||
font-family: monospace; | ||
margin: 0.5rem 0; | ||
} | ||
[theme="dark"] .code { | ||
background: $ui-secondary; | ||
color: white; | ||
} |
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,44 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import styles from './data-url.css'; | ||
|
||
/** | ||
* @param {string} dataURI data: URI | ||
* @returns {string} A hopefully human-readable version | ||
*/ | ||
const decodeDataURI = dataURI => { | ||
const delimeter = dataURI.indexOf(','); | ||
if (delimeter === -1) { | ||
return dataURI; | ||
} | ||
const contentType = dataURI.substring(0, delimeter); | ||
const data = dataURI.substring(delimeter + 1); | ||
if (contentType.endsWith(';base64')) { | ||
try { | ||
return atob(data); | ||
} catch (e) { | ||
return dataURI; | ||
} | ||
} | ||
try { | ||
return decodeURIComponent(data); | ||
} catch (e) { | ||
return dataURI; | ||
} | ||
}; | ||
|
||
const DataURL = props => ( | ||
<textarea | ||
className={styles.code} | ||
value={decodeDataURI(props.url)} | ||
readOnly | ||
spellCheck={false} | ||
autoComplete="off" | ||
/> | ||
); | ||
|
||
DataURL.propTypes = { | ||
url: PropTypes.string.isRequired | ||
}; | ||
|
||
export default DataURL; |
Oops, something went wrong.