Skip to content

Commit

Permalink
add additional languages and customize prism theme (#16)
Browse files Browse the repository at this point in the history
* add additional languages for prism

* set up custom theme for prism

* customize according to solarized dark theme

* add custom syntax highlighting from react-native

* rename theme file, add Kotlin, fix one ObjC block

Co-authored-by: Bartosz Kaszubowski <gosimek@gmail.com>
  • Loading branch information
teikjun and Simek committed Oct 20, 2020
1 parent 467d87d commit d27e445
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/native-components-ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ Until now we've only returned a `MKMapView` instance from our manager's `-(UIVie

Note that all `RCTBubblingEventBlock` must be prefixed with `on`. Next, declare an event handler property on `RNTMapManager`, make it a delegate for all the views it exposes, and forward events to JS by calling the event handler block from the native view.

```objectivec{9,17,31-48}
```objectivec
// RNTMapManager.m

#import <MapKit/MapKit.h>
Expand Down
128 changes: 128 additions & 0 deletions website/core/PrismTheme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
var theme = {
plain: {
color: '#FFFFFF',
background: '#282C34',
},
styles: [
// other modifications
{
types: ['property'],
style: {
color: '#2aa198',
},
},
// solarized-dark theme
{
types: ['attr-name', 'comment', 'prolog', 'doctype', 'cdata'],
style: {
color: '#93a1a1',
},
},

{
types: ['punctuation'],
style: {
color: '#657b83' /* base00 */,
},
},
{
types: ['namespace'],
style: {
opacity: 0.7,
},
},
{
types: ['deleted'],
style: {
color: '#d33682' /* magenta */,
},
},
{
types: ['selector', 'char', 'builtin', 'url', 'inserted'],
style: {
color: '#2aa198' /* cyan */,
},
},
{
types: ['entity'],
style: {
color: '#2aa198' /* cyan */,
},
},
{
types: ['atrule'],
style: {
color: '#859900' /* yellow */,
},
},
{
types: ['important', 'variable'],
style: {
color: '#cb4b16' /* orange */,
},
},
{
types: ['important', 'bold'],
style: {
fontWeight: 'bold',
},
},
{
types: ['italic'],
style: {
fontStyle: 'italic',
},
},
{
types: ['entity'],
style: {
cursor: 'help',
},
},
// react-native theme
{
types: ['attr-name', 'keyword'],
style: {
color: '#c5a5c5',
},
},
{
types: ['string', 'regex', 'attr-value'],
style: {
color: '#8dc891',
},
},
{
types: ['number', 'constant', 'symbol'],
style: {
color: '#5a9bcf',
},
},
{
types: ['boolean'],
style: {
color: '#ff8b50',
},
},
{
types: ['class-name'],
style: {
color: '#fac863',
},
},
{
types: ['function'],
style: {
color: '#79b6f2',
},
},
{
types: ['operator', 'tag'],
style: {
color: '#fc929e',
},
},
],
};

module.exports = theme;
5 changes: 5 additions & 0 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ module.exports = {
prism: {
defaultLanguage: 'jsx',
},
prism: {
defaultLanguage: 'jsx',
theme: require('./core/PrismTheme'),
additionalLanguages: ['java', 'kotlin', 'objectivec', 'swift'],
},
navbar: {
title: 'React Native',
logo: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ Until now we've only returned a `MKMapView` instance from our manager's `-(UIVie

Note that all `RCTBubblingEventBlock` must be prefixed with `on`. Next, declare an event handler property on `RNTMapManager`, make it a delegate for all the views it exposes, and forward events to JS by calling the event handler block from the native view.

```objectivec{9,17,31-48}
```objectivec
// RNTMapManager.m

#import <MapKit/MapKit.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ Until now we've only returned a `MKMapView` instance from our manager's `-(UIVie

Note that all `RCTBubblingEventBlock` must be prefixed with `on`. Next, declare an event handler property on `RNTMapManager`, make it a delegate for all the views it exposes, and forward events to JS by calling the event handler block from the native view.

```objectivec{9,17,31-48}
```objectivec
// RNTMapManager.m

#import <MapKit/MapKit.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ Until now we've only returned a `MKMapView` instance from our manager's `-(UIVie

Note that all `RCTBubblingEventBlock` must be prefixed with `on`. Next, declare an event handler property on `RNTMapManager`, make it a delegate for all the views it exposes, and forward events to JS by calling the event handler block from the native view.

```objectivec{9,17,31-48}
```objectivec
// RNTMapManager.m

#import <MapKit/MapKit.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ Until now we've only returned a `MKMapView` instance from our manager's `-(UIVie

Note that all `RCTBubblingEventBlock` must be prefixed with `on`. Next, declare an event handler property on `RNTMapManager`, make it a delegate for all the views it exposes, and forward events to JS by calling the event handler block from the native view.

```objectivec{9,17,31-48}
```objectivec
// RNTMapManager.m

#import <MapKit/MapKit.h>
Expand Down

0 comments on commit d27e445

Please sign in to comment.