Skip to content

Commit a267482

Browse files
committed
feat(inline): added inline style handling and some styling to properly position the next element
1 parent 1a5d04b commit a267482

5 files changed

Lines changed: 11 additions & 9 deletions

File tree

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-simple-styleable-select",
3-
"version": "1.0.0",
3+
"version": "1.1.2",
44
"description": "",
55
"license": "MIT",
66
"author": "Daniel Shaefer",
@@ -18,7 +18,7 @@
1818
"mobile",
1919
"responsive"
2020
],
21-
"main": "src/SimpleSelect.js",
21+
"main": "dist/SimpleSelect.js",
2222
"babel": {
2323
"presets": [
2424
"@babel/preset-react"
@@ -40,7 +40,7 @@
4040
"build": "react-scripts build",
4141
"test": "react-scripts test --env=jsdom",
4242
"eject": "react-scripts eject",
43-
"prepublish": "rm -rf dist && mkdir dist && babel src -d dist --copy-files"
43+
"prepublish": "rm -rf dist && babel src"
4444
},
4545
"browserslist": [
4646
">0.2%",

src/SimpleSelect.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.mySelectDefault {
2-
display: flex;
32
position: relative;
3+
margin-right: 0.5em;
4+
vertical-align: bottom;
45
}
56

67
/*TODO: Extract out variable styles into separate class: e.g. roundedCorners*/
@@ -14,7 +15,7 @@
1415
padding: 0.2em 0.2em 0.2em 0.2em; /*the right padding is much larger to allow for the absolute positioning of the dropdowncontainer*/
1516

1617
min-height: 2.2em; /*this is here to handle empty state not shrinking the field set too much. You can remove it this if you don't mind an empty select being compressed.*/
17-
min-width: 200px;
18+
min-width: 50px;
1819

1920
/*these 2 make placement and alignment of selected values and the cancel button easy*/
2021
display: flex;

src/SimpleSelect.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ class SimpleSelect extends React.Component {
174174
});
175175

176176
const style = {
177-
width: this.state.width ? this.state.width : "100%"
177+
width: this.state.width ? this.state.width : "100%",
178+
display: this.props.inline ? 'inline-block' : 'block'
178179
};
179180
const fixedHeightClassName = this.props.fixedHeight ? "fixedHeight" : "";
180181
const cornerClassName = this.props.hasSharpCorners ? "" : "roundedCorners";

src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function App() {
3636
}
3737
return (
3838
<div className="App">
39-
<h1>Simple, Styleable, React Select Component</h1>
39+
<h1 style={{ textAlign: 'center'}}>Simple, Styleable, React Select Component</h1>
4040
<h3 style={{ textAlign: "left" }}>
4141
<ul>
4242
<li>Small codebase - easily customized</li>
@@ -77,8 +77,9 @@ function App() {
7777
width="200px"//Non-cancelable
7878
/>
7979
<SimpleSelect id="5" options={flagOptions} onChange={onChange} width="300px" legendLabel="Custom Option Label Render"
80-
renderOptionLabel={flagOptionLabelRender}
80+
renderOptionLabel={flagOptionLabelRender} inline
8181
/>
82+
<div style={{display:'inline-block', height: '2.5em', lineHeight:'2.5em', verticalAlign:'middle', border:'1px solid red'}}>Testing inline positioning</div>
8283
</div>
8384
);
8485
}

src/styles.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
.App {
22
font-family: Lato, sans-serif;
3-
text-align: center;
43
}

0 commit comments

Comments
 (0)