Skip to content

Commit

Permalink
#5156 -- removed the popup & added acs style button that updates the …
Browse files Browse the repository at this point in the history
…fromState
  • Loading branch information
Mikhail Vialov committed Sep 10, 2024
1 parent bdcf2ce commit 89c721f
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 20 deletions.
20 changes: 20 additions & 0 deletions packages/ketcher-react/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,23 @@ export const KETCHER_MACROMOLECULES_ROOT_NODE_SELECTOR = `.${EditorClassName}`;
export const STRUCT_SERVICE_NO_RENDER_INITIALIZED_EVENT =
'struct-service-no-render-initialized';
export const STRUCT_SERVICE_INITIALIZED_EVENT = 'struct-service-initialized';
export const ACS_STYLE_DEFAULT_SETTINGS = {
atomColoring: false,
font: '30px Arial',
fontsz: 10,
fontszUnit: 'pt',
fontszsub: 10,
fontszsubUnit: 'pt',
reactionComponentMarginSize: 1.6,
reactionComponentMarginSizeUnit: 'pt',
imageResolution: '600',
bondLength: 14.4,
bondLengthUnit: 'pt',
bondSpacing: 18,
bondThickness: 0.6,
bondThicknessUnit: 'pt',
stereoBondWidth: 2,
stereoBondWidthUnit: 'pt',
hashSpacing: 2.5,
hashSpacingUnit: 'pt',
};
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ const render: {
title: 'Bond thickness',
type: 'integer',
default: defaultBondThickness,
minimum: 1,
minimum: 0.1,
maximum: 96,
},
bondThicknessUnit: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
***************************************************************************/

@import '../../../../../../../style/variables.less';
@import '../../../../../../../style/mixins.less';

.headerContent {
display: flex;
Expand All @@ -30,15 +31,15 @@
color: @color-icon-active;
padding: 0;
font-size: 0;

input[type='file'] {
display: none;
}

&:hover {
color: @color-icon-hover;
}

&:disabled {
color: @color-icon-disabled;
}
Expand All @@ -54,7 +55,7 @@
}

ul {
> li {
>li {
padding: 10px 16px;
}
}
Expand All @@ -73,8 +74,9 @@
top: 0;
}

span > div,
select, input {
span>div,
select,
input {
width: 120px;
margin-right: auto;
}
Expand All @@ -92,23 +94,29 @@
overflow: hidden;

fieldset[disabled] {
label > span {
label>span {
opacity: 0.3;
}

label > div {
label>div {
opacity: 0.6;
}
}

> header{
flex-shrink: 0;
box-shadow: 0 2px 4px 0 @color-accordion-shadow;
z-index: 10;
}
>header {
flex-shrink: 0;
box-shadow: 0 2px 4px 0 @color-accordion-shadow;
z-index: 10;
}

>footer {
box-shadow: 0 -2px 4px 0 @color-accordion-shadow;
z-index: 10;
}
}

.acsStyleButton {
margin-right: auto;

> footer {
box-shadow: 0 -2px 4px 0 @color-accordion-shadow;
z-index: 10;
}
.button-primary();
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import settingsSchema, {
import fieldGroups from './fieldGroups';
import { isEqual } from 'lodash';
import { Icon } from 'components';
import { ACS_STYLE_DEFAULT_SETTINGS } from 'src/constants';

interface SettingsProps extends BaseProps {
initState: any;
Expand All @@ -59,6 +60,7 @@ interface SettingsProps extends BaseProps {
interface SettingsCallProps extends BaseCallProps {
onOpenFile: (any) => void;
onReset: () => void;
onACSStyle: (result) => void;
}

const defaultSettings = getDefaultOptions();
Expand Down Expand Up @@ -143,7 +145,6 @@ const SettingsDialog = (props: Props) => {
label: 'General',
content: (
<fieldset>
<Field name="isACSStyle" />
<Field
name="resetToSelect"
component={Select}
Expand Down Expand Up @@ -318,6 +319,23 @@ const SettingsDialog = (props: Props) => {
),
};

const onACSStyle = () => {
prop.onACSStyle({
...formState.result,
...ACS_STYLE_DEFAULT_SETTINGS,
});
};

const ACSStyleButton = (
<button
className={classes.acsStyleButton}
key="acsstylebutton"
onClick={onACSStyle}
>
ACS Style
</button>
);

const tabs = [
generalTab,
stereoTab,
Expand All @@ -335,7 +353,7 @@ const SettingsDialog = (props: Props) => {
valid={() => formState.valid}
params={prop}
buttonsNameMap={{ OK: 'Apply' }}
buttons={['Cancel', 'OK']}
buttons={[ACSStyleButton, 'Cancel', 'OK']}
withDivider
needMargin={false}
headerContent={
Expand Down Expand Up @@ -380,6 +398,9 @@ const mapDispatchToProps = (dispatch, ownProps) => ({
dispatch(saveSettings(res));
ownProps.onOk(res);
},
onACSStyle: (result) => {
dispatch(updateFormState({ result }));
},
});

const Settings = connect(mapStateToProps, mapDispatchToProps)(SettingsDialog);
Expand Down

0 comments on commit 89c721f

Please sign in to comment.