-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add settings menu and allow customization of print options
- Loading branch information
Showing
9 changed files
with
1,008 additions
and
106 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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,70 @@ | ||
import React, { FC, useState } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { Button, Icon, Modal, Message } from 'semantic-ui-react'; | ||
import { AutoForm } from 'uniforms-semantic'; | ||
|
||
import { setSettings } from '../api/actions'; | ||
import { createBridge } from '../api/lib'; | ||
import { State } from '../api/store'; | ||
import { Settings } from '../api/types'; | ||
|
||
const formSchema = createBridge({ | ||
title: 'Settings', | ||
type: 'object', | ||
properties: { | ||
pageWidth: { type: 'integer' }, | ||
pageHeight: { type: 'integer' }, | ||
cardRadius: { type: 'number' }, | ||
symbolMargin: { type: 'number' }, | ||
rotateSymbols: { type: 'boolean' }, | ||
}, | ||
}); | ||
|
||
interface Props { | ||
settings: Settings, | ||
setSettings: typeof setSettings; | ||
} | ||
|
||
const SettingsComponent: FC<Props> = ({ | ||
settings, | ||
setSettings, | ||
}) => { | ||
const [open, setOpen] = useState(false); | ||
|
||
return ( | ||
<Modal | ||
onClose={() => setOpen(false)} | ||
onOpen={() => setOpen(true)} | ||
open={open} | ||
dimmer="blurring" | ||
trigger={ | ||
<Button> | ||
<Icon name="cog"/> | ||
Settings | ||
</Button> | ||
} | ||
> | ||
<Modal.Header>Adjust settings for the print</Modal.Header> | ||
<Modal.Content> | ||
<AutoForm | ||
schema={formSchema} | ||
model={settings} | ||
onSubmit={(model) => { | ||
setSettings(model); | ||
setOpen(false); | ||
}} | ||
/> | ||
<Message success header="Tips:" list={[ | ||
'Page sizes and card radius are in millimeters', | ||
'Symbol margin is a percentage of a symbol that should be left as a margin between other symbols', | ||
'If you rotate symbols, the margin value should be negative to allow overlap since rotated symbols are smaller', | ||
'Experiment and see what fit best for your pictures!' | ||
]}/> | ||
</Modal.Content> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default connect((state: State) => ({ settings: state.settings }), { | ||
setSettings, | ||
})(SettingsComponent); |