-
Notifications
You must be signed in to change notification settings - Fork 36
add padding option #2018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gurjit03
wants to merge
12
commits into
KhalisFoundation:dev
Choose a base branch
from
gurjit03:add-update-margin-option
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add padding option #2018
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e45daaa
chore: created padding tools component
gurjit03 f710556
chore: adds padding tools state
gurjit03 7d5c6f1
Merge branch 'dev' of github.com:KhalisFoundation/sttm-desktop into a…
gurjit03 9f32806
chore: renamed as portfinder
gurjit03 cedaced
chore: adds boolean variable
gurjit03 978ee56
feat: creates padding tools UI, and state
gurjit03 8c89ce5
chore: adds padding tools for testing
gurjit03 84f386b
style: fixes padding tools styles
gurjit03 13d918b
style: adds viewer related padding and styles
gurjit03 8f7dd6d
feat: adds padding tools
gurjit03 f0e2bd4
style: fixes padding issues
gurjit03 3859406
style: updates width
gurjit03 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,102 @@ | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import { useStoreActions, useStoreState } from 'easy-peasy'; | ||
import { convertToCamelCase } from '../../common/utils'; | ||
|
||
const icons = [ | ||
{ | ||
name: 'minus', | ||
actionName: 'Padding', | ||
}, | ||
{ | ||
name: 'plus', | ||
actionName: 'Padding', | ||
}, | ||
]; | ||
const PADDING_VARIANTS = ['top', 'right', 'bottom', 'left']; | ||
const PADDING_MAX = 48; | ||
const PADDING_MIN = 0; | ||
|
||
const PaddingTools = (props) => { | ||
const viewerSettingsStore = useStoreState((state) => state.viewerSettings); | ||
const { setPaddingToolsOpen } = useStoreActions((state) => state.viewerSettings); | ||
|
||
const createViewerSettingObject = ({ name, variant }) => { | ||
const payload = { type: variant }; | ||
const currentPadding = parseInt(viewerSettingsStore.containerPadding[variant], 10); | ||
|
||
if (name === 'minus') { | ||
payload.value = currentPadding > PADDING_MIN ? currentPadding - 1 : PADDING_MIN; | ||
} else if (name === 'plus') { | ||
payload.value = currentPadding < PADDING_MAX ? currentPadding + 1 : PADDING_MAX; | ||
} | ||
|
||
return { | ||
actionName: 'setPadding', | ||
payload, | ||
settingType: 'viewerSettings', | ||
}; | ||
}; | ||
|
||
const createPaddingIcon = ({ name, variant }) => { | ||
const currentPadding = parseInt(viewerSettingsStore.containerPadding[variant], 10); | ||
const isMinusIcon = name === 'minus'; | ||
const isIconDisabled = isMinusIcon | ||
? currentPadding === PADDING_MIN | ||
: currentPadding === PADDING_MAX; | ||
return ( | ||
<i | ||
disabled={isIconDisabled} | ||
className={isMinusIcon ? 'fa fa-minus-circle' : 'fa fa-plus-circle'} | ||
onClick={() => { | ||
if (!isIconDisabled) { | ||
const viewerSettingObj = createViewerSettingObject({ name, variant }); | ||
global.platform.ipc.send('update-global-setting', JSON.stringify(viewerSettingObj)); | ||
} | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
const createPaddingChanger = (variant) => { | ||
const iconValue = viewerSettingsStore.containerPadding[variant]; | ||
|
||
return ( | ||
<div className="paddingtool"> | ||
<h4 className="paddingtool-title">{`Padding-${convertToCamelCase(variant)}`}</h4> | ||
<div className="paddingtool-icons"> | ||
{createPaddingIcon({ name: icons[0].name, variant })} | ||
<p className="paddingtool-icon-value">{iconValue}</p> | ||
{createPaddingIcon({ name: icons[1].name, variant })} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
return ( | ||
<div className={`slide-paddingtools`}> | ||
<div | ||
className="quicktool-header" | ||
onClick={() => setPaddingToolsOpen(!viewerSettingsStore.paddingToolsOpen)} | ||
> | ||
Padding Tools | ||
<i className={`fa fa-caret-${viewerSettingsStore.paddingToolsOpen ? 'up' : 'down'}`}></i> | ||
</div> | ||
{viewerSettingsStore.paddingToolsOpen && ( | ||
<div | ||
className={`paddingtool-body paddingtool-${ | ||
props.isMiscSlide ? 'announcement' : 'gurbani' | ||
}`} | ||
> | ||
{PADDING_VARIANTS.map((variant) => createPaddingChanger(variant))} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
PaddingTools.propTypes = { | ||
isMiscSlide: PropTypes.bool, | ||
}; | ||
|
||
export default PaddingTools; |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we reduce the duplicacy in this part of code?
And do something along the lines of
I am not sure if above is correct, but just wanted to give an idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@indersinghkhalis thanks ji, will have a look asap.