Skip to content

Commit

Permalink
[custom-font]: init
Browse files Browse the repository at this point in the history
  • Loading branch information
Georgy Perepechko (merelj) committed Oct 4, 2020
1 parent 3225c2e commit 8e9b6bf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ const Textarea = styled(TextareaAutosize)<ExampleTextProps>`
flex-grow: 1;
color: ${props => (props.theme.main === 'dark' ? '#fff' : '#14213d')};
background-color: transparent;
font-family: Roboto;
font-family: ${props => (props.theme && props.theme.font
? props.theme.font
: 'Roboto'
)};
font-size: ${props => (props.smallerFont ? '1.2em' : '1.61em')};
${props => (props.showCopyCursor ? 'cursor: text;' : '')};
Expand Down
16 changes: 16 additions & 0 deletions stories/Thing.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState } from 'react';
import { ThemeProvider } from 'styled-components';
import { InOutTextarea, Props, InOptions, OutOptions } from '../src';

export default {
Expand Down Expand Up @@ -135,3 +136,18 @@ export const Default = (props?: Partial<Props>) => {
</div>
);
};

const fonts = ['monospace', 'Roboto', 'Arial', 'Comic Sans']
export const CustomFont = (props?: Partial<Props>) => {
const [font, setFont] = React.useState(fonts[0]);
return (
<ThemeProvider theme={{ font }}>
select font:{' '}
<select onChange={(v) => setFont(v.target.value)}>
{fonts.map(f => <option value={f}>{f}</option>)}
</select>
<hr/>
<Default/>
</ThemeProvider>
);
}

0 comments on commit 8e9b6bf

Please sign in to comment.