Skip to content
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

feat: disabled attribute for form fields #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lizard-boy
Copy link

Resolves Instawork#292

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This pull request introduces a 'disabled' attribute for form fields across the Hyperview framework, enhancing form control and user experience.

  • Implemented 'disabled' attribute in date fields, picker fields, select components, switches, and text inputs
  • Added new style modifiers for disabled and selected-disabled states in stylesheets
  • Updated component logic to handle disabled states, preventing user interaction when disabled
  • Deprecated 'editable' attribute in favor of 'disabled' for text fields
  • Enhanced type definitions to support new disabled functionality across components

19 file(s) reviewed, 18 comment(s)
Edit PR Review Bot Settings

Comment on lines +65 to +67
<modifier disabled="true">
<style borderBottomColor="#FAFAFA"/>
</modifier>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider using a more distinct visual style for disabled fields

Comment on lines +37 to +39
<modifier disabled="true">
<style borderBottomColor="#FAFAFA"/>
</modifier>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider adding more styles for the disabled state, such as a different text color or opacity

@@ -132,6 +153,31 @@ tags: forms
</option>
<view style="Select__Separator"/>
</select-multiple>
<text style="Description">Disabled</text>
<select-multiple name="choice2" style="Select">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Duplicate name attribute 'choice2' used for disabled select-multiple

Comment on lines 36 to +40
<switch style="switch" name="switch1" value="on"/>
</view>
<view style="FormGroup">
<text style="label">Switch on, disabled</text>
<switch style="switch" name="switch2" value="on" disabled="true"/>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: The name 'switch2' is used for both the enabled and disabled 'on' switches. Consider using unique names for each switch

Comment on lines +22 to 26
<style id="switch-styled" color="#E1E1E1" backgroundColor="red">
<modifier selected="true">
<style backgroundColor="#550000" color="#ffaaaa"/>
</modifier>
</style>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: The styled switch doesn't have disabled states defined. Consider adding disabled and selectedDisabled modifiers for consistency

Comment on lines +77 to +82
const selectedDisabledStyle = StyleSheet.flatten(
createStyleProp(this.props.element, this.props.stylesheets, {
disabled: true,
selected: true,
}),
);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: selectedDisabledStyle is defined but not used. Consider applying this style when the switch is both selected and disabled.

Comment on lines +41 to +49
const editableAttr = props.element.getAttribute('editable');
if (editableAttr) {
console.warn(
'Deprecation notice: `editable` attribute is deprecated and will be removed in a future version. Use `disabled` attribute instead.',
);
}
const editable =
editableAttr !== 'false' &&
props.element.getAttribute('disabled') !== 'true';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider using a separate function for attribute parsing and deprecation warnings to improve readability and maintainability.

Comment on lines +256 to +257
disabled: StyleSheet,
selectedDisabled: StyleSheet,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider adding comments to explain the purpose of these new style properties

Comment on lines +288 to +289
disabled?: ?boolean,
selectedDisabled?: ?boolean,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Add JSDoc comments to describe these new options

Comment on lines +288 to +289
disabled?: ?boolean,
selectedDisabled?: ?boolean,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Ensure consistent naming: consider using isDisabled instead of disabled for boolean props

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "disabled" modifier
1 participant