forked from rioukkevin/vscode-git-commit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat(Configurator): add title setting to configurator
- Loading branch information
RIOU Kevin
committed
Jul 19, 2022
1 parent
0ee3e22
commit 1694815
Showing
9 changed files
with
246 additions
and
3 deletions.
There are no files selected for viewing
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,36 @@ | ||
import React, { FC, useContext } from 'react'; | ||
import { LineElement } from '../typings/Editor'; | ||
import { IStoreDefaultVariableValue } from '../typings/Store'; | ||
import { Store } from '../utils/store'; | ||
import { parseVariableFromTemplate } from '../utils/template'; | ||
import VariableDisplayTitleInput from './core/VariableDisplayTitleInput'; | ||
|
||
interface IProps {} | ||
|
||
const VariablesDisplayTitlesInput: FC<IProps> = (props) => { | ||
const { variablesDisplayTitles, setVariableDisplayTitle, template } = | ||
useContext(Store); | ||
|
||
const templateVariables = | ||
parseVariableFromTemplate(template as LineElement[]) ?? []; | ||
|
||
const availableVariables = [...templateVariables]; | ||
|
||
return ( | ||
<div style={{ width: '100%' }}> | ||
{availableVariables.map((av, i) => ( | ||
<VariableDisplayTitleInput | ||
key={i} | ||
name={av} | ||
value={variablesDisplayTitles[av]} | ||
onChange={(value: IStoreDefaultVariableValue) => | ||
setVariableDisplayTitle(av, value) | ||
} | ||
onDelete={() => setVariableDisplayTitle(av, undefined)} | ||
/> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default VariablesDisplayTitlesInput; |
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,20 @@ | ||
import React, { FC, useContext } from 'react'; | ||
import { Store } from '../utils/store'; | ||
import Pre from './core/Pre'; | ||
|
||
interface IProps {} | ||
|
||
const VariablesDisplayTitlesRenderer: FC<IProps> = (props) => { | ||
const { variablesDisplayTitles } = useContext(Store); | ||
return ( | ||
<Pre> | ||
{`"vscodeGitCommit.variablesDisplayTitles": ${JSON.stringify( | ||
{ ...variablesDisplayTitles }, | ||
null, | ||
2 | ||
)}`} | ||
</Pre> | ||
); | ||
}; | ||
|
||
export default VariablesDisplayTitlesRenderer; |
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,62 @@ | ||
import { IconButton, Input } from '@chakra-ui/react'; | ||
import React, { FC, useEffect, useState } from 'react'; | ||
import styles from '../../styles/DefaultVariablesValuesInput.module.css'; | ||
import { DeleteIcon } from '@chakra-ui/icons'; | ||
import { IStoreVariableDisplayTitle } from '../../typings/Store'; | ||
|
||
interface IProps { | ||
name: string; | ||
value: IStoreVariableDisplayTitle; | ||
onChange: (value: IStoreVariableDisplayTitle) => IStoreVariableDisplayTitle; | ||
onDelete: () => void; | ||
} | ||
|
||
const VariableDisplayTitleInput: FC<IProps> = (props) => { | ||
const { name, value, onChange, onDelete } = props; | ||
|
||
const [internalValue, setInternalValue] = | ||
useState<IStoreVariableDisplayTitle>(value); | ||
|
||
const handleChangeValue = (e: any) => { | ||
const newValue = e.target.value.length === 0 ? undefined : e.target.value; | ||
onChange(newValue); | ||
setInternalValue(newValue); | ||
}; | ||
|
||
useEffect(() => { | ||
setInternalValue(value); | ||
}, [value]); | ||
|
||
return ( | ||
<> | ||
<h3 className={styles.name} key={name}> | ||
{name} | ||
</h3> | ||
<div className={styles.container}> | ||
<div className={styles.input}> | ||
<Input | ||
size="sm" | ||
placeholder="default value..." | ||
value={internalValue ?? ''} | ||
onChange={handleChangeValue} | ||
className={styles.label} | ||
variant="filled" | ||
/> | ||
</div> | ||
<IconButton | ||
disabled={!internalValue} | ||
className={styles.deleteIcon} | ||
aria-label="copy" | ||
icon={<DeleteIcon />} | ||
color="#000000" | ||
backgroundColor="#EEF2F6" | ||
_hover={{ backgroundColor: '#db4437', color: '#FBFFFF' }} | ||
size="sm" | ||
onClick={onDelete} | ||
/> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default VariableDisplayTitleInput; |
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