-
Notifications
You must be signed in to change notification settings - Fork 50
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
Update company design #4995
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ad1f896
Restyle and refactor BdbDetail
Bestem0r c72a6ec
Restyle and refactor BdbDetail
Bestem0r 57aaed4
Fix semester status change
Bestem0r d83c1e6
Add icon, refactor FileUpload
Bestem0r 430536b
Fix import order
Bestem0r efe6398
Center content
Bestem0r a01abd3
Revert global table change
Bestem0r 3c29731
Merge branch 'master' into update-company-design
Bestem0r 955a113
Apply changes from feedback
Bestem0r d3d57e9
Fix import order
Bestem0r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,7 @@ | |
.textContainer { | ||
width: max-content; | ||
} | ||
|
||
.overflowWrap { | ||
overflow-wrap: anywhere; | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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