Skip to content

Commit

Permalink
Revert "[PBNTR-479] Expose margin bottom on Text Input within Typeahe…
Browse files Browse the repository at this point in the history
…ad" (#3676)

Reverts #3654
  • Loading branch information
nidaqg authored Sep 9, 2024
1 parent 328fc93 commit f31bf17
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 208 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,29 @@ const RadioChildren = (props) => {
<div>
<Radio
label="Select"
marginBottom="sm"
name="Group1"
tabIndex={0}
value="Select"
{...props}
>
<Select
marginBottom="none"
minWidth="xs"
options={options}
/>
</Radio>
<Radio
label="Typeahead"
marginBottom="sm"
name="Group1"
tabIndex={0}
value="Typeahead"
{...props}
>
<Typeahead
marginBottom="none"
minWidth="xs"
options={options}
/>
</Radio>
<br />
<Radio
defaultChecked={false}
label="Typography"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
}
}
.text_input_wrapper {
margin-bottom: 1rem;
input::placeholder,
.text_input .placeholder {
@include pb_body_light_dark;
Expand Down
13 changes: 0 additions & 13 deletions playbook/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,4 @@ test('should pass className prop', () => {

const kit = screen.getByTestId('typeahead-test')
expect(kit).toHaveClass(className)
})

test('typeahead textinput has mb_sm class by default', () => {
render(
<Typeahead
data={{ testid: 'default-mb-test' }}
options={options}
/>
)

const kit = screen.getByTestId('default-mb-test')
const textInput = kit.querySelector(".pb_text_input_kit")
expect(textInput).toHaveClass("mb_sm")
})
9 changes: 1 addition & 8 deletions playbook/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ type TypeaheadProps = {
getOptionLabel?: string | (() => any),
getOptionValue?: string | (() => any),
name?: string,
marginBottom?: "none" | "xxs" | "xs" | "sm" | "md" | "lg" | "xl",
} & GlobalProps

export type SelectValueType = {
Expand Down Expand Up @@ -77,18 +76,12 @@ const Typeahead = ({
htmlOptions = {},
id,
loadOptions = noop,
marginBottom = "sm",
...props
}: TypeaheadProps) => {
const selectProps = {
cacheOptions: true,
components: {
Control: (controlProps: any) => (
<Control
{...controlProps}
marginBottom={marginBottom}
/>
),
Control,
ClearIndicator,
IndicatorsContainer,
IndicatorSeparator: null as null,
Expand Down
39 changes: 16 additions & 23 deletions playbook/app/pb_kits/playbook/pb_typeahead/components/Control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,23 @@ import TextInput from '../../pb_text_input/_text_input'

type Props = {
selectProps: any,
marginBottom?: string,
}

const TypeaheadControl = (props: Props) => {
const { selectProps, marginBottom } = props
const { dark, error, label } = selectProps

return (
<div className="pb_typeahead_wrapper">
<TextInput
dark={dark}
error={error}
label={label}
marginBottom={marginBottom}
>
<Flex>
<components.Control
className="text_input"
{...props}
/>
</Flex>
</TextInput>
</div>
)
}
const TypeaheadControl = (props: Props) => (
<div className="pb_typeahead_wrapper">
<TextInput
dark={props.selectProps.dark}
error={props.selectProps.error}
label={props.selectProps.label}
>
<Flex>
<components.Control
className="text_input"
{...props}
/>
</Flex>
</TextInput>
</div>
)

export default TypeaheadControl

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions playbook/app/pb_kits/playbook/pb_typeahead/docs/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ examples:
- typeahead_inline: Inline
- typeahead_multi_kit: Multi Kit Options
- typeahead_error_state: Error State
- typeahead_margin_bottom: Margin Bottom

react:
- typeahead_default: Default
Expand All @@ -24,4 +23,3 @@ examples:
- typeahead_async_createable: Createable (+ Async Data)
- typeahead_error_state: Error State
- typeahead_custom_menu_list: Custom MenuList
- typeahead_margin_bottom: Margin Bottom
1 change: 0 additions & 1 deletion playbook/app/pb_kits/playbook/pb_typeahead/docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ export { default as TypeaheadCreateable } from './_typeahead_createable.jsx'
export { default as TypeaheadAsyncCreateable } from './_typeahead_async_createable.jsx'
export { default as TypeaheadErrorState } from './_typeahead_error_state.jsx'
export { default as TypeaheadCustomMenuList } from './_typeahead_custom_menu_list.jsx'
export { default as TypeaheadMarginBottom } from './_typeahead_margin_bottom.jsx'
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
label: object.label,
name: object.name,
value: object.value,
placeholder: object.placeholder,
margin_bottom: "none",
placeholder: object.placeholder
}) %>
<%= pb_rails("list", props: { ordered: false, borderless: false, xpadding: true, role: "status", aria: { live: "polite" }, data: { pb_typeahead_kit_results: true } }) do %>
<% end %>
Expand Down
7 changes: 1 addition & 6 deletions playbook/app/pb_kits/playbook/pb_typeahead/typeahead.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ class Typeahead < Playbook::KitBase
default: false
prop :label
prop :load_options
prop :margin_bottom, type: Playbook::Props::Enum,
values: %w[none xxs xs sm md lg xl],
default: "sm"
prop :multi_kit, type: Playbook::Props::String,
default: ""
prop :name
Expand All @@ -39,8 +36,7 @@ class Typeahead < Playbook::KitBase
prop :value

def classname
default_margin_bottom = margin_bottom.present? ? "" : " mb_sm"
generate_classname("pb_typeahead_kit") + default_margin_bottom
generate_classname("pb_typeahead_kit")
end

def inline_class
Expand Down Expand Up @@ -69,7 +65,6 @@ def typeahead_react_options
inline: inline,
isMulti: is_multi,
label: label,
marginBottom: margin_bottom,
multiKit: multi_kit,
name: name,
options: options,
Expand Down
2 changes: 1 addition & 1 deletion playbook/spec/pb_kits/playbook/kits/typeahead_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

describe "#classname" do
it "returns namespaced class name", :aggregate_failures do
expect(subject.new({}).classname).to eq "pb_typeahead_kit mb_sm"
expect(subject.new({}).classname).to eq "pb_typeahead_kit"
end
end
end

0 comments on commit f31bf17

Please sign in to comment.