Skip to content

Commit 6e32d1d

Browse files
committed
add UI for uploading images
1 parent 0f91f9f commit 6e32d1d

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

src/components/settings/RelayInfoSettings.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect } from 'react';
1+
import React, { useEffect, useState} from 'react';
22
import { Form, Input, Select, Tooltip } from 'antd';
33
import { QuestionCircleOutlined, InfoCircleOutlined, UserOutlined, KeyOutlined, UploadOutlined } from '@ant-design/icons';
44
import useGenericSettings from '@app/hooks/useGenericSettings';
@@ -10,7 +10,7 @@ const { TextArea } = Input;
1010

1111
const RelayInfoSettings: React.FC = () => {
1212
const { settings, loading, error, fetchSettings, updateSettings, saveSettings } = useGenericSettings('relay_info');
13-
13+
const [image, setImage] = useState<string | null>(null);
1414
const [form] = Form.useForm();
1515

1616
// Update form values when settings change
@@ -25,6 +25,10 @@ const RelayInfoSettings: React.FC = () => {
2525
updateSettings(changedValues);
2626
};
2727

28+
const onUploadIcon = (url: string) => { // use as onUploadIcon prop in Upload Component
29+
setImage(url);
30+
};
31+
2832
// Common NIPs that relays might support
2933
const nipOptions = [
3034
{ value: 1, label: 'NIP-01: Basic protocol flow' },
@@ -86,6 +90,9 @@ const RelayInfoSettings: React.FC = () => {
8690
<S.InputFieldWithPrefix
8791
suffix={<S.UploadButton size='small' aria-label='Upload Relay Icon' icon={<UploadOutlined />} > Upload Relay Icon</S.UploadButton>}
8892
/>
93+
{image && (
94+
<S.UploadedImageWrapper><img src={image} alt="" /></S.UploadedImageWrapper>
95+
)}
8996
</Form.Item>
9097
<Form.Item
9198
name="relaydescription"

src/components/settings/Settings.styles.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import styled from 'styled-components';
2-
import { Input, InputNumber, Select, Button} from 'antd';
2+
import { Input, InputNumber, Select, Button } from 'antd';
33

44
export const InputField = styled(Input)`
55
border-radius: 7px !important;
@@ -56,16 +56,33 @@ export const InputNumberField = styled(InputNumber)`
5656
border-color: var(--ant-primary-5) !important;
5757
box-shadow: 0 0 0 2px var(--ant-primary-color-outline) !important;
5858
}
59-
.anticon-up.ant-input-number-handler-up-inner, .anticon-down.ant-input-number-handler-down-inner {
59+
.anticon-up.ant-input-number-handler-up-inner,
60+
.anticon-down.ant-input-number-handler-down-inner {
6061
color: var(--text-main-color) !important;
61-
opacity: 0.7 !important;}
62+
opacity: 0.7 !important;
63+
}
6264
`;
6365

6466
export const SelectField = styled(Select)`
65-
.ant-select-arrow, .ant-select-clear{
67+
.ant-select-arrow,
68+
.ant-select-clear {
6669
color: var(--text-main-color) !important;
6770
}
68-
`
71+
`;
6972
export const UploadButton = styled(Button)`
70-
margin-right:.5rem;
71-
`;
73+
margin-right: 0.5rem;
74+
`;
75+
export const UploadedImageWrapper = styled.div`
76+
border-radius: 100%;
77+
margin 1rem 0 0 0;
78+
width: 12rem;
79+
height: 12rem;
80+
overflow: hidden;
81+
82+
img {
83+
width: 100%;
84+
height: 100%;
85+
object-fit: cover;
86+
display: block;
87+
}
88+
`;

0 commit comments

Comments
 (0)