Expandable TextField from the react Material-UI components
Material-UI Expandable TextField is a React-Redux component that uses Material-UI to create a Expandable TextField.
The main reason to use only containers and not prepared TextFields with this behavior is that you can now change the style of the TextField and the IconButtons as you like. You can also use other components to hide and display them on click events.
You can also place the Button and the TextField in seperate places. They bound only by the same id
you give them.
You can try it out the DEMO.
This project can be istalled as npm module using following command:
npm i -S material-ui-expandable-text-field
For this project components to work in your application after the npm installetion you have to be shure that everithing is correctly setup for Material-UI to work. You can find more about that here.
No mather where you store your reducers the project components need access to a specific reducer and its state. For that we add to our reducers index.js
file where we compine all our reducers the following two reduces:
import { combineReducers } from 'redux';
import {expandableTextFields} from 'material-ui-expandable-text-field';
const reducers = combineReducers({
expandableTextFields
})
export default reducers;
That are the points we have to do before using this module in our application.
The module contains of two main parts:
All can be imported like this:
import {
ExpandableTextFieldContainer,
ETFIconButtonContainer
} from 'material-ui-expandable-text-field'
All of them are just containers in witch you can put all your other application components:
<div>
<ETFIconButtonContainer
value={true}
hideOnOpen={true}
id={'1'}>
<ActionSearch></ActionSearch>
</ETFIconButtonContainer>
<ETFIconButtonContainer
value={false}
hideOnClose={true}
id={'1'}>
<NavigationClose></NavigationClose>
</ETFIconButtonContainer>
<ExpandableTextFieldContainer id={'1'}>
<TextField
floatingLabelText={'Text field with autofocus'}
ref={(ref) => {if(ref!=null){ref.focus()}}}
id={'1'}
/>
</ExpandableTextFieldContainer>
</div>
NOTICE: - both of those components need the propertie id to colaborate corectly. Each TextField witch is in a ExpandableTextFieldContainer should have a diferent id
.
You can also import the Actions from the module to trigger them when you want and without the prepared containers.
The actions available in this module are: setIsETFOpen
, toggleETF
.
We can import them from the module like this:
import {
ExpandableTextFieldContainer,
ETFIconButtonContainer,
setIsETFOpen,
toggleETF
} from 'material-ui-expandable-text-field'
An complete example with all the actions called can be found in the App.js of the demo part of this project.
ExpandableTextFieldContainer:
id
with witch we identify witch containers act togetherETFIconButtonContainer:
id
with witch we identify witch containers act togethertrue
the button will only make the TextField visible. If it is false
it can only hide the TextField and if you don’t set a value the ETFIconButtonContainer
will act as a toggler for the TextField visibility.true
the botton will hide when the TextField is opentrue
the botton will hide when the TextField is closedtrue
by clicking the button all other open ExpandabldeTextFields will closeOtheseEvery help no mather if it is a kritik, suggestion or pull request is welkome :)