diff --git a/.all-contributorsrc b/.all-contributorsrc index 14e3b37..a7c67e5 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -204,6 +204,60 @@ "code" ] }, + { + "login": "dmmulroy", + "name": "Dillon Mulroy", + "avatar_url": "https://avatars1.githubusercontent.com/u/2755722?v=4", + "profile": "https://dillonmulroy.com", + "contributions": [ + "code" + ] + }, + { + "login": "NARKOZ", + "name": "Nihad Abbasov", + "avatar_url": "https://avatars2.githubusercontent.com/u/253398?v=4", + "profile": "https://github.com/NARKOZ", + "contributions": [ + "code" + ] + }, + { + "login": "TorzuoliH", + "name": "Hugo Torzuoli", + "avatar_url": "https://avatars1.githubusercontent.com/u/7328625?v=4", + "profile": "https://torzuolih.github.io", + "contributions": [ + "doc" + ] + }, + { + "login": "bruno02221", + "name": "Bruno C. Couto", + "avatar_url": "https://avatars1.githubusercontent.com/u/1906977?v=4", + "profile": "https://github.com/bruno02221", + "contributions": [ + "code" + ] + }, + { + "login": "molnarmark", + "name": "Mark Molnar", + "avatar_url": "https://avatars2.githubusercontent.com/u/13263073?v=4", + "profile": "https://github.com/molnarmark", + "contributions": [ + "code" + ] + }, + { + "login": "TETRA2000", + "name": "Takahiko Inayama", + "avatar_url": "https://avatars1.githubusercontent.com/u/1459450?v=4", + "profile": "https://www.behance.net/tetra2000", + "contributions": [ + "code" + ] + }, { "login": "martinfrancois", "name": "François Martin", diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..43c97e7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/LICENSE b/LICENSE index ac302a3..eda08ba 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Dawn Labs +Copyright (c) 2018 Dawn Labs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 0d182e5..747f2ab 100644 --- a/README.md +++ b/README.md @@ -41,8 +41,12 @@ After you've customized your image you can either Tweet a link to the image, or ## Community Check out these projects our awesome community has created: +- [IntelliJ IDEA `carbon-now-sh`](https://plugins.jetbrains.com/plugin/10469-carbon-now-sh) - Open up the selection in your current IntelliJ IDEA file in Carbon through a context menu - [Atom `carbon-now-sh`](https://atom.io/packages/carbon-now-sh) - Open up your current Atom file in Carbon with `shift-cmd-A` - [VS Code `carbon-now-sh`](https://marketplace.visualstudio.com/items?itemName=ericadamski.carbon-now-sh) - Open up your current VS Code file in Carbon with command `carbon` +- [Sublime Text 3 `carbon-now-sh`](https://github.com/molnarmark/carbonSublime) - Open up the selection in your current Sublime Text 3 file with a custom bound key +- [Vim `carbon-now-sh`](https://github.com/kristijanhusak/vim-carbon-now-sh) - Open up the selection in your current Vim/Neovim using function `CarbonNowSh()` +- [Emacs `carbon-now-sh`](https://github.com/veelenga/carbon-now-sh.el) - Open up the selection in your current Emacs using interactive function `carbon-now-sh` ## Contribute @@ -73,5 +77,6 @@ Thanks goes out to all these wonderful people ([emoji key](https://github.com/ke | [
briandennis](https://github.com/briandennis)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=briandennis "Code") [πŸ“–](https://github.com/dawnlabs/carbon/commits?author=briandennis "Documentation") [πŸš‡](#infra-briandennis "Infrastructure (Hosting, Build-Tools, etc)") [πŸ‘€](#review-briandennis "Reviewed Pull Requests") | [
mfix22](https://github.com/mfix22)
[πŸ’¬](#question-mfix22 "Answering Questions") [πŸ’»](https://github.com/dawnlabs/carbon/commits?author=mfix22 "Code") [πŸ€”](#ideas-mfix22 "Ideas, Planning, & Feedback") | [
jakedex](https://github.com/jakedex)
[πŸ’¬](#question-jakedex "Answering Questions") [πŸ’»](https://github.com/dawnlabs/carbon/commits?author=jakedex "Code") [🎨](#design-jakedex "Design") [πŸ“Ή](#video-jakedex "Videos") | [
andrewda](https://github.com/andrewda)
[πŸ’¬](#question-andrewda "Answering Questions") [πŸ’»](https://github.com/dawnlabs/carbon/commits?author=andrewda "Code") [πŸ›](https://github.com/dawnlabs/carbon/issues?q=author%3Aandrewda "Bug reports") [πŸ‘€](#review-andrewda "Reviewed Pull Requests") | [
yeskunall](https://github.com/yeskunall)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=yeskunall "Code") [πŸ“–](https://github.com/dawnlabs/carbon/commits?author=yeskunall "Documentation") [πŸ”§](#tool-yeskunall "Tools") [πŸ›](https://github.com/dawnlabs/carbon/issues?q=author%3Ayeskunall "Bug reports") | [
stoshfabricius](https://github.com/stoshfabricius)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=stoshfabricius "Code") | [
jkling38](https://github.com/jkling38)
[πŸ“–](https://github.com/dawnlabs/carbon/commits?author=jkling38 "Documentation") | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | [
otobrglez](https://github.com/otobrglez)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=otobrglez "Code") | [
darahak](https://github.com/darahak)
[πŸ“–](https://github.com/dawnlabs/carbon/commits?author=darahak "Documentation") | [
dom96](https://github.com/dom96)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=dom96 "Code") | [
elrumordelaluz](https://github.com/elrumordelaluz)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=elrumordelaluz "Code") | [
cjb](https://github.com/cjb)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=cjb "Code") | [
Krzysztof-Cieslak](https://github.com/Krzysztof-Cieslak)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=Krzysztof-Cieslak "Code") | [
fernahh](https://github.com/fernahh)
[πŸ“–](https://github.com/dawnlabs/carbon/commits?author=fernahh "Documentation") | -| [
g3r4n](https://github.com/g3r4n)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=g3r4n "Code") | [
Mat Gadd](http://drarok.com/)
[πŸ›](https://github.com/dawnlabs/carbon/issues?q=author%3ADrarok "Bug reports") [πŸ’»](https://github.com/dawnlabs/carbon/commits?author=Drarok "Code") | [
Brad Davies](https://bradlab.co.uk)
[πŸ›](https://github.com/dawnlabs/carbon/issues?q=author%3Avarbrad "Bug reports") [πŸ’»](https://github.com/dawnlabs/carbon/commits?author=varbrad "Code") | [
Rafael CΓ’mara](http://www.rafaelcamaram.com/)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=rafaelcamaram "Code") | [
Gleb Bahmutov](https://glebbahmutov.com/)
[⚠️](https://github.com/dawnlabs/carbon/commits?author=bahmutov "Tests") [πŸ”§](#tool-bahmutov "Tools") | [
IvΓ‘n MunguΓ­a](https://ivan-munguia.netlify.com)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=warborn "Code") | [
François Martin](https://github.com/martinfrancois)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=martinfrancois "Code") | +| [
g3r4n](https://github.com/g3r4n)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=g3r4n "Code") | [
Mat Gadd](http://drarok.com/)
[πŸ›](https://github.com/dawnlabs/carbon/issues?q=author%3ADrarok "Bug reports") [πŸ’»](https://github.com/dawnlabs/carbon/commits?author=Drarok "Code") | [
Brad Davies](https://bradlab.co.uk)
[πŸ›](https://github.com/dawnlabs/carbon/issues?q=author%3Avarbrad "Bug reports") [πŸ’»](https://github.com/dawnlabs/carbon/commits?author=varbrad "Code") | [
Rafael CΓ’mara](http://www.rafaelcamaram.com/)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=rafaelcamaram "Code") | [
Gleb Bahmutov](https://glebbahmutov.com/)
[⚠️](https://github.com/dawnlabs/carbon/commits?author=bahmutov "Tests") [πŸ”§](#tool-bahmutov "Tools") | [
IvΓ‘n MunguΓ­a](https://ivan-munguia.netlify.com)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=warborn "Code") | [
Dillon Mulroy](https://dillonmulroy.com)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=dmmulroy "Code") | +| [
Nihad Abbasov](https://github.com/NARKOZ)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=NARKOZ "Code") | [
Hugo Torzuoli](https://torzuolih.github.io)
[πŸ“–](https://github.com/dawnlabs/carbon/commits?author=TorzuoliH "Documentation") | [
Bruno C. Couto](https://github.com/bruno02221)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=bruno02221 "Code") | [
Mark Molnar](https://github.com/molnarmark)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=molnarmark "Code") | [
Takahiko Inayama](https://www.behance.net/tetra2000)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=TETRA2000 "Code") | [
François Martin](https://github.com/martinfrancois)
[πŸ’»](https://github.com/dawnlabs/carbon/commits?author=martinfrancois "Code") | diff --git a/bin/deploy.sh b/bin/deploy.sh index 107b2a3..13b4efc 100755 --- a/bin/deploy.sh +++ b/bin/deploy.sh @@ -1,15 +1,15 @@ #!/usr/bin/env bash # Don't deploy if commit contains WIP +# TODO revisit this when deploy is stable +exit 0 set -e if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then - if [[ -z ${NOW_TOKEN+x} ]]; then - if [[ $(git log -1 --pretty=%B --no-merges) != *"WIP"* ]]; then - NOW_URL=$(now -e NODE_ENV=production --public --no-clipboard --team=dawn --token="$NOW_TOKEN") + if [[ $(git log -1 --pretty=%B --no-merges) != *"WIP"* ]]; then + NOW_URL=$(now -e NODE_ENV=production --public --no-clipboard --team=dawn --token="$NOW_TOKEN") || exit 0 - curl -X POST \ + curl -X POST \ -H 'Content-type: application/json' \ --data "{\"text\": \":small_red_triangle: New Carbon PR Deployment for \\n:rocket: $NOW_URL\"}" \ "$DAWN_SLACK_WEBHOOK" - fi fi fi diff --git a/components/BackgroundSelect.js b/components/BackgroundSelect.js index a6e9cb4..27e5eb6 100644 --- a/components/BackgroundSelect.js +++ b/components/BackgroundSelect.js @@ -3,7 +3,8 @@ import enhanceWithClickOutside from 'react-click-outside' import { SketchPicker } from 'react-color' import WindowPointer from './WindowPointer' import ImagePicker from './ImagePicker' -import { COLORS } from '../lib/constants' +import { COLORS, DEFAULT_BG_COLOR } from '../lib/constants' +import { validateColor } from '../lib/colors' import { parseRGBA, capitalizeFirstLetter } from '../lib/util' class BackgroundSelect extends React.Component { @@ -46,6 +47,10 @@ class BackgroundSelect extends React.Component { .replace(/\//g, '/') : background + if (!validateColor(background)) { + background = DEFAULT_BG_COLOR + } + return (
diff --git a/components/Carbon.js b/components/Carbon.js index 82eb69f..e59654f 100644 --- a/components/Carbon.js +++ b/components/Carbon.js @@ -13,25 +13,10 @@ import { DEFAULT_LANGUAGE, LANGUAGES, LANGUAGE_MODE_HASH, - LANGUAGE_NAME_HASH + LANGUAGE_NAME_HASH, + DEFAULT_SETTINGS } from '../lib/constants' -const DEFAULT_SETTINGS = { - paddingVertical: '50px', - paddingHorizontal: '50px', - marginVertical: '45px', - marginHorizontal: '45px', - backgroundMode: 'color', - backgroundColor: 'rgba(171, 184, 195, 1)', - dropShadowOffsetY: '20px', - dropShadowBlurRadius: '68px', - theme: 'seti', - windowTheme: 'none', - language: DEFAULT_LANGUAGE, - fontFamily: 'Hack', - fontSize: '14px' -} - class Carbon extends React.Component { constructor(props) { super(props) @@ -42,6 +27,7 @@ class Carbon extends React.Component { } this.handleLanguageChange = this.handleLanguageChange.bind(this) + this.handleTitleBarChange = this.handleTitleBarChange.bind(this) this.codeUpdated = this.codeUpdated.bind(this) } @@ -68,6 +54,10 @@ class Carbon extends React.Component { this.props.updateCode(newCode) } + handleTitleBarChange(newTitle) { + this.props.updateTitleBar(newTitle) + } + handleLanguageChange = debounce( (newCode, config) => { const props = (config && config.customProps) || this.props @@ -119,7 +109,12 @@ class Carbon extends React.Component { if (this.state.loading === false) { content = (
- {config.windowControls ? : null} + {config.windowControls ? ( + + ) : null} this.codeUpdated(code)} diff --git a/components/Dropdown.js b/components/Dropdown.js index 36f553f..6e180dc 100644 --- a/components/Dropdown.js +++ b/components/Dropdown.js @@ -1,145 +1,171 @@ import React from 'react' -import enhanceWithClickOutside from 'react-click-outside' +import Downshift from 'downshift' import ArrowDown from './svg/Arrowdown' -import Checkmark from './svg/Checkmark' +import CheckMark from './svg/Checkmark' import { COLORS } from '../lib/constants' -class Dropdown extends React.Component { - constructor(props) { - super(props) - this.state = { - isVisible: false - } - this.select = this.select.bind(this) - this.toggle = this.toggle.bind(this) - } - - select(item) { - if (this.props.selected !== item) { - this.props.onChange(item) - } - } - - toggle() { - this.setState({ isVisible: !this.state.isVisible }) - } +const Dropdown = ({ button, color, list, selected, onChange }) => { + return ( + it === selected)} + itemToString={item => item.name} + onChange={onChange} + stateReducer={reduceState(list)} + /> + ) +} - handleClickOutside() { - this.setState({ isVisible: false }) +const reduceState = list => (state, changes) => { + switch (changes.type) { + case Downshift.stateChangeTypes.keyDownArrowUp: + case Downshift.stateChangeTypes.keyDownArrowDown: + return { ...changes, selectedItem: list[changes.highlightedIndex] } + default: + return changes } +} - renderListItems() { - return this.props.list.map((item, i) => ( -
- {item.name} - {this.props.selected === item ? : null} - +
+ ) +} - .dropdown-list-item:hover { - background: ${COLORS.HOVER}; - } +const SelectedItem = ({ children, isOpen, color, ...rest }) => { + const itemColor = color || COLORS.SECONDARY - .dropdown-list-item:last-of-type { - border-bottom: none; - border-radius: 0px 0px 2px 2px; - } - `} + return ( + + {children} +
+
- )) - } - - render() { - const color = this.props.color || COLORS.SECONDARY - - // find longest list value in number of characters - const list = this.props.button ? [...this.props.list, this.props.selected] : this.props.list - const MIN_WIDTH = list.reduce( - (max, { name }) => (name && name.length > max ? name.length : max), - 0 - ) - - return ( -
-
- {this.props.selected.name} -
- -
-
-
{this.renderListItems()}
- + + ) +} - .dropdown-display span { - color: ${color}; - } +const ListItems = ({ children, color }) => { + return ( +
    + {children} + +
+ ) +} - .dropdown-display:hover { - background: ${COLORS.HOVER}; - } +const ListItem = ({ children, color, isHighlighted, isSelected, ...rest }) => { + const itemColor = color || COLORS.SECONDARY + + return ( +
  • + {children} + {isSelected ? : null} + +
  • + ) +} - .is-visible + .dropdown-list { - display: block; - } +function minWidth(isButton, selected, list) { + const items = isButton ? [...list, selected] : list - .dropdown-list { - display: none; - margin-top: -1px; - border: 1px solid ${color}; - border-radius: 0px 0px 3px 3px; - max-height: 350px; - overflow-y: scroll; - } - `} -
    - ) - } + return items.reduce((max, { name }) => { + const wordSize = name.length * 10 + 32 + return wordSize > max ? wordSize : max + }, 0) } -export default enhanceWithClickOutside(Dropdown) +export default Dropdown diff --git a/components/ExportSizeSelect.js b/components/ExportSizeSelect.js new file mode 100644 index 0000000..e881fd3 --- /dev/null +++ b/components/ExportSizeSelect.js @@ -0,0 +1,88 @@ +import React from 'react' +import { COLORS } from '../lib/constants' +import Checkmark from './svg/Checkmark' +import { EXPORT_SIZES } from '../lib/constants' + +export default class extends React.Component { + constructor(props) { + super() + this.state = { isVisible: false } + this.select = this.select.bind(this) + this.toggle = this.toggle.bind(this) + } + + select(exportSize) { + if (this.props.selected !== exportSize) { + this.props.onChange(exportSize) + } + } + + toggle() { + this.setState({ isVisible: !this.state.isVisible }) + } + + renderExportSizes() { + return EXPORT_SIZES.map((exportSize, i) => { + return ( +
    + {exportSize.name} + {this.props.selected === exportSize.id ? : null} + +
    + ) + }) + } + + render() { + const selectedExportSize = + EXPORT_SIZES.filter(exportSize => exportSize.id === this.props.selected)[0] || {} + return ( +
    +
    + Export Size + {selectedExportSize.name} +
    +
    {this.renderExportSizes()}
    + +
    + ) + } +} diff --git a/components/FontSelect.js b/components/FontSelect.js index c5ff603..442ba2b 100644 --- a/components/FontSelect.js +++ b/components/FontSelect.js @@ -48,7 +48,7 @@ export default class extends React.Component { } render() { - const selectedFont = FONTS.filter(font => font.id === this.props.selected)[0] + const selectedFont = FONTS.filter(font => font.id === this.props.selected)[0] || {} return (
    ( - + ) export default Footer diff --git a/components/Header.js b/components/Header.js index f00bc8d..cc061cc 100644 --- a/components/Header.js +++ b/components/Header.js @@ -2,7 +2,7 @@ import React from 'react' import Logo from './svg/Logo' const Header = ({ enableHeroText }) => ( -
    +
    +
    ) export default Header diff --git a/components/Page.js b/components/Page.js index e08d49e..9071455 100644 --- a/components/Page.js +++ b/components/Page.js @@ -4,7 +4,7 @@ import Header from './Header' import Footer from './Footer' export default ({ children, enableHeroText }) => ( -
    +
    {children}
    @@ -19,5 +19,5 @@ export default ({ children, enableHeroText }) => ( align-items: center; } `} -
    + ) diff --git a/components/Settings.js b/components/Settings.js index 4746007..edebcaf 100644 --- a/components/Settings.js +++ b/components/Settings.js @@ -3,6 +3,7 @@ import enhanceWithClickOutside from 'react-click-outside' import SettingsIcon from './svg/Settings' import ThemeSelect from './ThemeSelect' import FontSelect from './FontSelect' +import ExportSizeSelect from './ExportSizeSelect' import Slider from './Slider' import Toggle from './Toggle' import WindowPointer from './WindowPointer' @@ -71,6 +72,7 @@ class Settings extends React.Component { + + +
    diff --git a/components/style/Font.js b/components/style/Font.js index d5c1de0..83d6f8d 100644 --- a/components/style/Font.js +++ b/components/style/Font.js @@ -1,5 +1,18 @@ export default () => (