Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update company design #4995

Merged
merged 10 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/components/TextWithIcon/TextWithIcon.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
.textContainer {
width: max-content;
}

.overflowWrap {
overflow-wrap: anywhere;
}
Comment on lines +10 to +12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels dangerous. Have you checked how this affects other uses of the component? Like on the event detail page

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I quickly checked through all uses now and couldn't spot any problems

4 changes: 3 additions & 1 deletion app/components/TextWithIcon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ const TextWithIcon = ({
) : (
<>{icon}</>
)}
<div>{iconRight ? <></> : <>{content}</>}</div>
<div className={styles.overflowWrap}>
{iconRight ? <></> : <>{content}</>}
</div>
Bestem0r marked this conversation as resolved.
Show resolved Hide resolved
</Flex>
);
};
Expand Down
102 changes: 43 additions & 59 deletions app/components/Upload/FileUpload.tsx
Original file line number Diff line number Diff line change
@@ -1,72 +1,56 @@
import { Button } from '@webkom/lego-bricks';
import { Component } from 'react';
import { Button, Icon } from '@webkom/lego-bricks';
import { UploadIcon } from 'lucide-react';
import { useState, useRef } from 'react';
import { connect } from 'react-redux';
import { uploadFile } from 'app/actions/FileActions';
import styles from './FileUpload.css';

type State = {
pending: boolean;
};
type Props = {
uploadFile: (arg0: { file: File }) => Promise<any>;
type FileUploadProps = {
uploadFile: (arg0: { file: File }) => Promise<{
meta: { fileKey: string; fileToken: string };
}>;
onChange: (arg0: string, arg1: string) => void;
className?: string;
};

class FileUpload extends Component<Props, State> {
input: HTMLInputElement | null | undefined;
state = {
pending: false,
};
handleClick = () => {
this.input && this.input.click();
const FileUpload = ({ uploadFile, onChange, className }: FileUploadProps) => {
const [pending, setPending] = useState(false);
const inputRef = useRef<HTMLInputElement | null>(null);

const handleClick = () => {
inputRef.current && inputRef.current.click();
};
handleChange = (e) => {
const file = e.target.files[0];
this.setState({
pending: true,
});
this.props
.uploadFile({
file,
})
.then(({ meta }) => {
this.setState({
pending: false,
});
this.props.onChange(meta.fileKey, meta.fileToken);
})
.catch((error) => {
this.setState({
pending: false,

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files?.[0];
if (file) {
setPending(true);
uploadFile({ file })
.then(({ meta }) => {
setPending(false);
onChange(meta.fileKey, meta.fileToken);
})
.catch((error) => {
setPending(false);
throw error;
});
throw error;
});
}
};

render() {
return (
<div>
<Button
isPending={this.state.pending}
onPress={this.handleClick}
className={this.props.className}
>
Last opp fil
</Button>
<input
ref={(ref) => (this.input = ref)}
className={styles.input}
onChange={this.handleChange}
type="file"
accept="application/pdf"
/>
</div>
);
}
}

const mapDispatchToProps = {
uploadFile,
return (
<div>
<Button isPending={pending} onPress={handleClick} className={className}>
Bestem0r marked this conversation as resolved.
Show resolved Hide resolved
<Icon name="upload" iconNode={<UploadIcon size={24} />} />
</Button>
Bestem0r marked this conversation as resolved.
Show resolved Hide resolved
<input
ref={inputRef}
className={styles.input}
Bestem0r marked this conversation as resolved.
Show resolved Hide resolved
onChange={handleChange}
type="file"
accept="application/pdf"
/>
</div>
);
};
export default connect(null, mapDispatchToProps)(FileUpload);

export default connect(null, { uploadFile })(FileUpload);
Loading
Loading