You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
carbon/lib/constants.js

644 lines
11 KiB
JavaScript

import toHash from 'tohash'
7 years ago
export const FONTS = [
{ id: 'Anonymous Pro', name: 'Anonymous Pro' },
{ id: 'Droid Sans Mono', name: 'Droid Sans Mono' },
{ id: 'Fantasque Sans Mono', name: 'Fantasque Sans Mono' },
{ id: 'Fira Code', name: 'Fira Code' },
{ id: 'Hack', name: 'Hack' },
{ id: 'IBM Plex Mono', name: 'IBM Plex Mono' },
{ id: 'Inconsolata', name: 'Inconsolata' },
{ id: 'Iosevka', name: 'Iosevka' },
{ id: 'Monoid', name: 'Monoid' },
{ id: 'Source Code Pro', name: 'Source Code Pro' },
{ id: 'Space Mono', name: 'Space Mono' },
{ id: 'Ubuntu Mono', name: 'Ubuntu Mono' }
]
export const THEMES = [
7 years ago
{
id: '3024-night',
name: '3024 Night'
},
{
id: 'blackboard',
name: 'Blackboard'
},
{
id: 'base16-dark',
name: 'Base 16 (Dark)'
},
{
id: 'base16-light',
name: 'Base 16 (Light)',
light: true
},
7 years ago
{
id: 'cobalt',
name: 'Cobalt'
},
{
id: 'dracula',
name: 'Dracula'
},
{
7 years ago
id: 'duotone-dark',
name: 'Duotone'
},
{
7 years ago
id: 'hopscotch',
name: 'Hopscotch'
},
{
id: 'lucario',
name: 'Lucario'
},
{
7 years ago
id: 'material',
name: 'Material'
},
{
7 years ago
id: 'monokai',
name: 'Monokai'
},
{
id: 'night-owl',
name: 'Night Owl'
},
{
id: 'nord',
name: 'Nord'
},
{
id: 'oceanic-next',
name: 'Oceanic Next'
},
{
id: 'one-light',
name: 'One Light',
light: true
},
{
id: 'one-dark',
name: 'One Dark'
},
{
id: 'panda-syntax',
name: 'Panda'
},
{
id: 'paraiso-dark',
name: 'Paraiso'
},
{
7 years ago
id: 'seti',
name: 'Seti'
},
{
id: 'solarized dark',
name: 'Solarized (Dark)',
link: 'solarized'
},
{
id: 'solarized light',
name: 'Solarized (Light)',
link: 'solarized',
light: true
},
{
id: 'tomorrow-night-bright',
name: 'Tomorrow Night'
},
{
7 years ago
id: 'twilight',
name: 'Twilight'
},
{
id: 'verminal',
name: 'Verminal'
},
{
7 years ago
id: 'yeti',
name: 'Yeti',
light: true
},
{
7 years ago
id: 'zenburn',
name: 'Zenburn'
}
]
export const THEMES_HASH = toHash(THEMES)
7 years ago
export const LANGUAGES = [
{
name: 'Auto',
mode: 'auto'
},
{
name: 'Apache',
mode: 'apache',
mime: 'text/apache',
custom: true
},
{
name: 'Bash',
mode: 'shell',
mime: 'application/x-sh'
},
{
name: 'Plain Text',
mode: 'text'
},
{
name: 'C',
mode: 'clike',
mime: 'text/x-csrc',
short: 'c'
},
{
name: 'C++',
mode: 'clike',
mime: 'text/x-c++src',
short: 'cpp'
},
{
name: 'C#',
mode: 'clike',
mime: 'text/x-csharp',
short: 'cs'
},
{
name: 'Clojure',
mode: 'clojure'
},
{
name: 'Cobol',
mode: 'cobol'
},
{
name: 'CoffeeScript',
mode: 'coffeescript'
},
{
name: 'Crystal',
mode: 'crystal'
},
{
name: 'CSS',
mode: 'css'
},
{
name: 'D',
mode: 'd'
},
{
name: 'Dart',
mode: 'dart'
},
{
name: 'Diff',
mode: 'diff',
mime: 'text/x-diff'
},
{
name: 'Django',
mode: 'django'
},
{
name: 'Docker',
mode: 'dockerfile'
},
{
name: 'Elixir',
mode: 'elixir',
custom: true
},
{
name: 'Elm',
mode: 'elm'
},
{
name: 'Erlang',
mode: 'erlang'
},
{
name: 'Fortran',
mode: 'fortran'
},
{
name: 'F#',
mode: 'mllike'
},
{
name: 'GraphQL',
mode: 'graphql',
custom: true
},
{
name: 'Go',
mode: 'go',
mime: 'text/x-go'
},
{
name: 'Groovy',
mode: 'groovy'
},
{
name: 'Handlebars',
mode: 'handlebars'
},
{
name: 'Haskell',
mode: 'haskell'
},
{
name: 'Haxe',
mode: 'haxe'
},
{
name: 'HTML',
mode: 'htmlmixed'
},
{
name: 'Java',
mode: 'clike',
mime: 'text/x-java',
short: 'java'
},
{
name: 'JavaScript',
mode: 'javascript',
short: 'javascript'
},
{
name: 'JSON',
mode: 'javascript',
mime: 'application/json',
short: 'json'
},
7 years ago
{
name: 'JSX',
mode: 'jsx'
7 years ago
},
{
name: 'Julia',
mode: 'julia'
},
{
name: 'Kotlin',
mode: 'clike',
mime: 'text/x-kotlin',
short: 'kotlin'
},
{
name: 'LaTeX',
mode: 'stex'
},
{
name: 'Lisp',
mode: 'commonlisp'
},
{
name: 'Lua',
mode: 'lua'
},
{
name: 'Markdown',
mode: 'markdown'
},
{
name: 'Mathematica',
mode: 'mathematica'
},
{
name: 'MATLAB/Octave',
mode: 'octave',
mime: 'text/x-octave'
},
{
name: 'MySQL',
mode: 'sql',
mime: 'text/x-mysql',
short: 'mysql'
},
{
name: 'N-Triples',
mode: 'ntriples',
mime: 'application/n-triples'
},
{
name: 'NGINX',
mode: 'nginx'
},
7 years ago
{
name: 'Nim',
mode: 'nimrod',
custom: true
7 years ago
},
{
name: 'Objective C',
mode: 'clike',
mime: 'text/x-objectivec',
short: 'objectivec'
},
{
name: 'OCaml',
mode: 'mllike'
},
{
name: 'Pascal',
mode: 'pascal'
},
{
name: 'Perl',
mode: 'perl'
},
{
name: 'PHP',
mode: 'php',
mime: 'text/x-php',
short: 'php'
},
{
name: 'PowerShell',
mode: 'powershell'
},
{
name: 'Python',
mode: 'python'
},
{
name: 'R',
mode: 'r'
},
{
name: 'Ruby',
mode: 'ruby'
},
{
name: 'Rust',
mode: 'rust'
},
{
name: 'Sass',
mode: 'sass'
},
{
name: 'Scala',
mode: 'clike',
mime: 'text/x-scala',
short: 'scala'
},
{
name: 'Smalltalk',
mode: 'smalltalk'
},
{
name: 'SPARQL',
mode: 'sparql',
mime: 'application/sparql-query'
},
{
name: 'SQL',
mode: 'sql'
},
{
name: 'Stylus',
mode: 'stylus',
mime: 'stylus'
},
{
name: 'Swift',
mode: 'swift'
},
{
name: 'TCL',
mode: 'tcl'
},
{
name: 'TOML',
mode: 'toml'
},
{
name: 'Turtle',
mode: 'turtle',
mime: 'text/turtle'
},
{
name: 'TypeScript',
mode: 'javascript',
mime: 'application/typescript',
short: 'typescript'
},
{
name: 'TSX',
mode: 'jsx',
mime: 'text/typescript-jsx',
short: 'tsx'
},
{
name: 'VB.NET',
mode: 'vb'
},
{
name: 'Verilog',
mode: 'verilog'
},
{
name: 'VHDL',
mode: 'vhdl'
},
{
name: 'Vue',
mode: 'vue'
},
{
name: 'XML',
mode: 'xml'
},
{
name: 'YAML',
mode: 'yaml'
}
]
export const EXPORT_SIZES = [
Add preset feature (#595) * Add preset feature without create * fix lint errors * Add presets to Editor state * add remove, update -> apply, omit presets * replace name with index, add undo functionality * fix reduce function * Tweaks: - Make remove filter setState atomic - Remove broken sCU in BackgroundSelect - Touch up style of arrow functions a little - Remove titleBar from default settings - Don't expose SETTINGS_KEYS - Use hasOwnProperty instead of includes() * refactor preset state into Settings * move format code into editor and make it work again * omit custom in applyPreset * move presets array state into Settings * keep custom sCU in BackgroundSelect * pull out inline objects * revert pages/index * increase Presets font-size, remove margin-top * Add ability to create presets * also enable passing exportSize as prop * move selectedPreset back into Settings (my bad Sean) * replace splice with filter, getSavedX -> getX * Revert "move selectedPreset back into Settings (my bad Sean)" This reverts commit ae5da4700ea36ad7c31e697e83a2724be4b448f4. * make sure background updates remove selected preset * selectedPreset -> preset * use onChange instead of selectPreset * use preset id's instead of indexes * bug fixes * use disabled instead of pointer-events * make .settings-presets-applied flex 💪 * make .settings-presets-arrow flex 💪 * move getPresets outside of `setState` * move inline styles to style tag * refactor using omitBy and isFunction * remove lodash.isfunction * fix applyPreset to disclude preset field * move omit to getSettingsFromProps * replace lodash.omit with omitBy solution * .includes -> .indexOf * add default preset and presetApplied state * fix lint error * remove presetApplied * add more default presets * fix default preset functionality * tweaks * preserve preset list scrollLeft b/w updates with a hack * Use ref for preset content * remove forwardRef
6 years ago
{ id: '1x', name: '1x', value: 1 },
{ id: '2x', name: '2x', value: 2 },
{ id: '4x', name: '4x', value: 4 }
]
export const EXPORT_SIZES_HASH = toHash(EXPORT_SIZES)
export const LANGUAGE_MIME_HASH = toHash(LANGUAGES, 'mime')
export const LANGUAGE_MODE_HASH = toHash(LANGUAGES, 'mode')
export const LANGUAGE_NAME_HASH = toHash(LANGUAGES, 'short')
export const DEFAULT_LANGUAGE = 'auto'
export const DEFAULT_THEME = THEMES_HASH.seti
export const DEFAULT_BG_COLOR = 'rgba(171, 184, 195, 1)'
export const DEFAULT_EXPORT_SIZE = EXPORT_SIZES_HASH['2x']
export const COLORS = {
BLACK: '#121212',
8 years ago
PRIMARY: '#F8E81C',
SECONDARY: '#fff',
7 years ago
GRAY: '#858585',
DARK_GRAY: '#393939',
HOVER: '#1F1F1F',
PURPLE: '#C198FB',
DARK_PURPLE: '#55436F',
RED: 'red'
}
export const DEFAULT_CODE = `const pluckDeep = key => obj => key.split('.').reduce((accum, key) => accum[key], obj)
const compose = (...fns) => res => fns.reduce((accum, next) => next(accum), res)
const unfold = (f, seed) => {
const go = (f, seed, acc) => {
const res = f(seed)
return res ? go(f, res[1], acc.concat([res[0]])) : acc
}
return go(f, seed, [])
}`
if (typeof window !== 'undefined' && typeof window.navigator !== 'undefined') {
const alreadyLoaded = new Set()
LANGUAGES.filter(language => language.mode !== 'auto' && language.mode !== 'text').forEach(
language => {
if (language.mode && !alreadyLoaded.has(language.mode)) {
alreadyLoaded.add(language.mode)
language.custom
? require(`./custom/modes/${language.mode}`)
: require(`codemirror/mode/${language.mode}/${language.mode}`)
}
}
)
}
export const DEFAULT_SETTINGS = {
Add preset feature (#595) * Add preset feature without create * fix lint errors * Add presets to Editor state * add remove, update -> apply, omit presets * replace name with index, add undo functionality * fix reduce function * Tweaks: - Make remove filter setState atomic - Remove broken sCU in BackgroundSelect - Touch up style of arrow functions a little - Remove titleBar from default settings - Don't expose SETTINGS_KEYS - Use hasOwnProperty instead of includes() * refactor preset state into Settings * move format code into editor and make it work again * omit custom in applyPreset * move presets array state into Settings * keep custom sCU in BackgroundSelect * pull out inline objects * revert pages/index * increase Presets font-size, remove margin-top * Add ability to create presets * also enable passing exportSize as prop * move selectedPreset back into Settings (my bad Sean) * replace splice with filter, getSavedX -> getX * Revert "move selectedPreset back into Settings (my bad Sean)" This reverts commit ae5da4700ea36ad7c31e697e83a2724be4b448f4. * make sure background updates remove selected preset * selectedPreset -> preset * use onChange instead of selectPreset * use preset id's instead of indexes * bug fixes * use disabled instead of pointer-events * make .settings-presets-applied flex 💪 * make .settings-presets-arrow flex 💪 * move getPresets outside of `setState` * move inline styles to style tag * refactor using omitBy and isFunction * remove lodash.isfunction * fix applyPreset to disclude preset field * move omit to getSettingsFromProps * replace lodash.omit with omitBy solution * .includes -> .indexOf * add default preset and presetApplied state * fix lint error * remove presetApplied * add more default presets * fix default preset functionality * tweaks * preserve preset list scrollLeft b/w updates with a hack * Use ref for preset content * remove forwardRef
6 years ago
paddingVertical: '56px',
paddingHorizontal: '56px',
marginVertical: '45px',
marginHorizontal: '45px',
backgroundImage: null,
backgroundImageSelection: null,
backgroundMode: 'color',
backgroundColor: DEFAULT_BG_COLOR,
dropShadow: true,
dropShadowOffsetY: '20px',
dropShadowBlurRadius: '68px',
theme: DEFAULT_THEME.id,
windowTheme: 'none',
language: DEFAULT_LANGUAGE,
fontFamily: 'Hack',
fontSize: '14px',
lineHeight: '133%',
windowControls: true,
widthAdjustment: true,
lineNumbers: false,
exportSize: '2x',
watermark: false,
squaredImage: false
}
Add preset feature (#595) * Add preset feature without create * fix lint errors * Add presets to Editor state * add remove, update -> apply, omit presets * replace name with index, add undo functionality * fix reduce function * Tweaks: - Make remove filter setState atomic - Remove broken sCU in BackgroundSelect - Touch up style of arrow functions a little - Remove titleBar from default settings - Don't expose SETTINGS_KEYS - Use hasOwnProperty instead of includes() * refactor preset state into Settings * move format code into editor and make it work again * omit custom in applyPreset * move presets array state into Settings * keep custom sCU in BackgroundSelect * pull out inline objects * revert pages/index * increase Presets font-size, remove margin-top * Add ability to create presets * also enable passing exportSize as prop * move selectedPreset back into Settings (my bad Sean) * replace splice with filter, getSavedX -> getX * Revert "move selectedPreset back into Settings (my bad Sean)" This reverts commit ae5da4700ea36ad7c31e697e83a2724be4b448f4. * make sure background updates remove selected preset * selectedPreset -> preset * use onChange instead of selectPreset * use preset id's instead of indexes * bug fixes * use disabled instead of pointer-events * make .settings-presets-applied flex 💪 * make .settings-presets-arrow flex 💪 * move getPresets outside of `setState` * move inline styles to style tag * refactor using omitBy and isFunction * remove lodash.isfunction * fix applyPreset to disclude preset field * move omit to getSettingsFromProps * replace lodash.omit with omitBy solution * .includes -> .indexOf * add default preset and presetApplied state * fix lint error * remove presetApplied * add more default presets * fix default preset functionality * tweaks * preserve preset list scrollLeft b/w updates with a hack * Use ref for preset content * remove forwardRef
6 years ago
export const DEFAULT_PRESET_ID = 'preset:4'
export const DEFAULT_PRESETS = [
{
...DEFAULT_SETTINGS,
icon: '/static/presets/4.png',
id: DEFAULT_PRESET_ID
},
{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(74,144,226,1)',
dropShadow: false,
theme: 'material',
fontFamily: 'Fira Code',
lineHeight: '152%',
icon: '/static/presets/7.png',
id: 'preset:7'
},
{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(248,231,28,1)',
dropShadow: false,
theme: 'blackboard',
fontFamily: 'Fira Code',
lineHeight: '152%',
icon: '/static/presets/8.png',
id: 'preset:8'
},
{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(182,162,145,1)',
dropShadow: false,
theme: 'zenburn',
windowTheme: 'bw',
lineHeight: '152%',
icon: '/static/presets/9.png',
id: 'preset:9'
},
{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(121,72,185,1)',
dropShadow: false,
theme: 'verminal',
windowTheme: 'bw',
fontFamily: 'Fira Code',
fontSize: '14px',
lineHeight: '143%',
icon: '/static/presets/0.png',
id: 'preset:0'
},
{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(239,40,44,1)',
theme: 'one-light',
lineHeight: '143%',
icon: '/static/presets/1.png',
id: 'preset:1'
},
{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(31,129,109,1)',
dropShadow: false,
theme: 'night-owl',
lineHeight: '143%',
windowControls: false,
icon: '/static/presets/2.png',
id: 'preset:2'
},
{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(249,237,212,1)',
theme: 'twilight',
fontFamily: 'IBM Plex Mono',
lineHeight: '143%',
icon: '/static/presets/3.png',
id: 'preset:3'
},
{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(222,171,99,1)',
theme: 'duotone-dark',
icon: '/static/presets/5.png',
id: 'preset:5'
},
{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(187,187,187,1)',
dropShadowOffsetY: '3px',
dropShadowBlurRadius: '13px',
theme: 'solarized light',
windowTheme: 'sharp',
icon: '/static/presets/6.png',
id: 'preset:6'
}
]