@rpg-engine/long-bow 0.5.75 → 0.5.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Dropdown.d.ts +1 -0
- package/dist/long-bow.cjs.development.js +10 -7
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +10 -7
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Dropdown.tsx +14 -6
- package/src/stories/Dropdown.stories.tsx +10 -2
package/package.json
CHANGED
|
@@ -12,12 +12,14 @@ export interface IDropdownProps {
|
|
|
12
12
|
options: IOptionsProps[];
|
|
13
13
|
width?: string;
|
|
14
14
|
onChange: (value: string) => void;
|
|
15
|
+
opensUp?: boolean; // Add a new prop to control the dropdown direction
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export const Dropdown: React.FC<IDropdownProps> = ({
|
|
18
19
|
options,
|
|
19
20
|
width,
|
|
20
21
|
onChange,
|
|
22
|
+
opensUp = false, // Default value is false
|
|
21
23
|
}) => {
|
|
22
24
|
const dropdownId = uuidv4();
|
|
23
25
|
|
|
@@ -36,10 +38,6 @@ export const Dropdown: React.FC<IDropdownProps> = ({
|
|
|
36
38
|
change = options.filter(o => o.value === selectedValue).length < 1;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
/**
|
|
40
|
-
* make a selection if there is no selected value already present
|
|
41
|
-
* or if there is a selected value but its not in new options
|
|
42
|
-
*/
|
|
43
41
|
if (change) {
|
|
44
42
|
setSelectedValue(firstOption.value);
|
|
45
43
|
setSelectedOption(firstOption.option);
|
|
@@ -63,7 +61,11 @@ export const Dropdown: React.FC<IDropdownProps> = ({
|
|
|
63
61
|
<label>▼</label> {selectedOption}
|
|
64
62
|
</DropdownSelect>
|
|
65
63
|
|
|
66
|
-
<DropdownOptions
|
|
64
|
+
<DropdownOptions
|
|
65
|
+
className="rpgui-dropdown-imp"
|
|
66
|
+
opened={opened}
|
|
67
|
+
opensUp={opensUp}
|
|
68
|
+
>
|
|
67
69
|
{options.map(option => {
|
|
68
70
|
return (
|
|
69
71
|
<li
|
|
@@ -100,6 +102,7 @@ const DropdownSelect = styled.p`
|
|
|
100
102
|
|
|
101
103
|
const DropdownOptions = styled.ul<{
|
|
102
104
|
opened: boolean;
|
|
105
|
+
opensUp: boolean; // Add a new prop to the styled component
|
|
103
106
|
}>`
|
|
104
107
|
position: absolute;
|
|
105
108
|
width: 100%;
|
|
@@ -107,7 +110,12 @@ const DropdownOptions = styled.ul<{
|
|
|
107
110
|
overflow-y: auto;
|
|
108
111
|
display: ${props => (props.opened ? 'block' : 'none')};
|
|
109
112
|
box-sizing: border-box;
|
|
110
|
-
|
|
113
|
+
bottom: ${props =>
|
|
114
|
+
props.opensUp ? '100%' : 'auto'}; // Adjust the position based on the prop
|
|
115
|
+
top: ${props =>
|
|
116
|
+
props.opensUp ? 'auto' : '100%'}; // Adjust the position based on the prop
|
|
117
|
+
margin: 0;
|
|
118
|
+
padding: 0;
|
|
111
119
|
@media (max-width: 768px) {
|
|
112
120
|
padding: 8px 0;
|
|
113
121
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Meta, Story } from '@storybook/react';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
3
4
|
import { RPGUIRoot } from '../../src';
|
|
4
5
|
import {
|
|
5
6
|
Dropdown,
|
|
@@ -14,12 +15,18 @@ const meta: Meta = {
|
|
|
14
15
|
|
|
15
16
|
export default meta;
|
|
16
17
|
|
|
17
|
-
const Template: Story<IDropdownProps> =
|
|
18
|
+
const Template: Story<IDropdownProps> = args => (
|
|
18
19
|
<RPGUIRoot>
|
|
19
|
-
<
|
|
20
|
+
<PushUp>
|
|
21
|
+
<Dropdown {...args} />
|
|
22
|
+
</PushUp>
|
|
20
23
|
</RPGUIRoot>
|
|
21
24
|
);
|
|
22
25
|
|
|
26
|
+
const PushUp = styled.div`
|
|
27
|
+
margin-top: 200px;
|
|
28
|
+
`;
|
|
29
|
+
|
|
23
30
|
export const Default = Template.bind({});
|
|
24
31
|
|
|
25
32
|
const options: IOptionsProps[] = [
|
|
@@ -43,4 +50,5 @@ const options: IOptionsProps[] = [
|
|
|
43
50
|
Default.args = {
|
|
44
51
|
options,
|
|
45
52
|
width: '100%',
|
|
53
|
+
opensUp: false,
|
|
46
54
|
};
|