-
Notifications
You must be signed in to change notification settings - Fork 703
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
Output settings form to react #5299
Open
michelinewu
wants to merge
19
commits into
master
Choose a base branch
from
mw_output_settings_react
base: master
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
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
95d4da5
Migrate Output settings to react. Styling WIP.
michelinewu 7bc8088
Styling for collapse form sections. Tab form sections styling WIP.
michelinewu 19b8f57
Advance form tabs.
michelinewu 34bea75
WIP: Input Resolution List
michelinewu 5104678
WIP
michelinewu 7426b84
Added input resolution field to output settings form.
michelinewu 322f2ee
WIP: input resolution field.
michelinewu d64fb63
WIP: obs form fields.
michelinewu be36d11
Fixes for form.
michelinewu af7d29d
Refactor to forward reference to components for validation.
michelinewu b82dc4a
Fix for uint field and css styling.
michelinewu 608aeb8
WIP
michelinewu eb6cab9
Simple output settings panels open by default and styling fixes.
michelinewu 9c9ff27
Refactor generic obs form tabbed group and refactor output settings f…
michelinewu 29a0eb6
Fix file input field.
michelinewu 8723ef6
Fix recording path selector in tests.
michelinewu 12686dd
Fix selectors for tests.
michelinewu 7c061db
Merge branch 'master' into mw_output_settings_react
michelinewu b8849ff
Merge branch 'master' into mw_output_settings_react
michelinewu 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import React, { useMemo, useState } from 'react'; | ||
import { useObsSettings } from './useObsSettings'; | ||
import { | ||
IObsSectionedFormGroupProps, | ||
ObsCollapsibleFormGroup, | ||
ObsForm, | ||
} from 'components-react/obs/ObsForm'; | ||
import Tabs from 'components-react/shared/Tabs'; | ||
import { $t } from 'services/i18n'; | ||
import cloneDeep from 'lodash/cloneDeep'; | ||
import { TObsFormData } from 'components/obs/inputs/ObsInput'; | ||
|
||
export function OutputSettings() { | ||
const { settingsFormData, saveSettings } = useObsSettings(); | ||
|
||
const type = settingsFormData[0].parameters[0].currentValue === 'Simple' ? 'collapsible' : 'tabs'; | ||
|
||
function onChange(formData: TObsFormData, ind: number) { | ||
const newVal = cloneDeep(settingsFormData); | ||
newVal[ind].parameters = formData; | ||
saveSettings(newVal); | ||
} | ||
const sections = settingsFormData.filter( | ||
section => section.parameters.filter(p => p.visible).length, | ||
); | ||
|
||
return ( | ||
<div className="form-groups" style={{ paddingBottom: '12px' }}> | ||
{type === 'tabs' && <ObsTabbedOutputFormGroup sections={sections} onChange={onChange} />} | ||
|
||
{type === 'collapsible' && ( | ||
<ObsCollapsibleFormGroup sections={sections} onChange={onChange} /> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export function ObsTabbedOutputFormGroup(p: IObsSectionedFormGroupProps) { | ||
const tabs = useMemo(() => { | ||
// combine all audio tracks into one tab | ||
const filtered = p.sections | ||
.filter(sectionProps => sectionProps.nameSubCategory !== 'Untitled') | ||
.filter(sectionProps => !sectionProps.nameSubCategory.startsWith('Audio - Track')) | ||
.map(sectionProps => sectionProps.nameSubCategory); | ||
|
||
filtered.splice(2, 0, 'Audio'); | ||
return filtered; | ||
}, [p.sections]); | ||
|
||
const [currentTab, setCurrentTab] = useState(p.sections[1].nameSubCategory); | ||
|
||
return ( | ||
<div className="section" key="tabbed-section" style={{ marginBottom: '24px' }}> | ||
{p.sections.map((sectionProps, ind) => ( | ||
<div className="section-content" key={`${sectionProps.nameSubCategory}${ind}`}> | ||
{sectionProps.nameSubCategory === 'Untitled' && ( | ||
<> | ||
<ObsForm | ||
value={sectionProps.parameters} | ||
onChange={formData => p.onChange(formData, ind)} | ||
/> | ||
<Tabs tabs={tabs} onChange={setCurrentTab} style={{ marginBottom: '24px' }} /> | ||
</> | ||
)} | ||
|
||
{sectionProps.nameSubCategory === currentTab && ( | ||
<ObsForm | ||
name={sectionProps.nameSubCategory} | ||
value={sectionProps.parameters} | ||
onChange={formData => p.onChange(formData, ind)} | ||
/> | ||
)} | ||
|
||
{currentTab === 'Audio' && sectionProps.nameSubCategory.startsWith('Audio - Track') && ( | ||
<div | ||
style={{ | ||
backgroundColor: 'var(--section-wrapper)', | ||
padding: '15px', | ||
marginBottom: '30px', | ||
borderRadius: '5px', | ||
}} | ||
> | ||
<h2 className="section-title">{$t(sectionProps.nameSubCategory)}</h2> | ||
<ObsForm | ||
value={sectionProps.parameters} | ||
onChange={formData => p.onChange(formData, ind)} | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
OutputSettings.page = 'Output'; |
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
Oops, something went wrong.
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.
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.
is there a reason to restructure the props and format them here instead of just doing this formatting before passing in the tabs under the
data
prop?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.
This is how it was done in the vue component.