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

Add disabled next and prev buttons #5

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions client/src/Annotator/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const Annotator = ({
hideHeaderText,
hideNext,
hidePrev,
disabledNextAndPrev,
hideClone,
hideSettings,
hideSave,
Expand Down Expand Up @@ -171,6 +172,7 @@ export const Annotator = ({
hideHeaderText={hideHeaderText}
hideNext={hideNext}
hidePrev={hidePrev}
disabledNextAndPrev={disabledNextAndPrev}
hideClone={hideClone}
hideSettings={hideSettings}
hideSave={hideSave}
Expand Down Expand Up @@ -216,6 +218,7 @@ Annotator.propTypes = {
hideHeaderText: PropTypes.bool,
hideNext: PropTypes.bool,
hidePrev: PropTypes.bool,
disabledNextAndPrev: PropTypes.bool,
hideClone: PropTypes.bool,
hideSettings: PropTypes.bool,
settings: PropTypes.object,
Expand Down
3 changes: 1 addition & 2 deletions client/src/DemoSite/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ export default () => {
setLoading(false);
}, []);



return (
<>
{ !showLabel ? ( // Render loading indicator if loading is true
Expand Down Expand Up @@ -159,6 +157,7 @@ export default () => {
changeSelectedImageIndex(isNaN(updatedIndex ) ? 0 : updatedIndex)
}}
hideSettings={true}
disabledNextAndPrev={settings.images.length <= 1}
selectedImageIndex={selectedImageIndex}
/>)}
</>
Expand Down
5 changes: 3 additions & 2 deletions client/src/MainLayout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const MainLayout = ({
hideHeaderText,
hideNext = false,
hidePrev = false,
disabledNextAndPrev,
hideClone = false,
hideSettings = false,
downloadImage = false,
Expand Down Expand Up @@ -221,8 +222,8 @@ export const MainLayout = ({
) : null,
].filter(Boolean)}
headerItems={[
!hidePrev && {name: "Prev"},
!hideNext && {name: "Next"},
!hidePrev && {name: "Prev", disabled: disabledNextAndPrev},
!hideNext && {name: "Next", disabled: disabledNextAndPrev},
state.annotationType !== "video"
? null
: !state.videoPlaying
Expand Down
12 changes: 6 additions & 6 deletions client/src/workspace/HeaderButton/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ const ButtonInnerContent = styled("div")(({ theme }) => ({
display: "flex",
flexDirection: "column",
}))
const IconContainer = styled("div")(({ textHidden }) => ({
color: colors.grey[700],
const IconContainer = styled("div")(({ textHidden, disabled }) => ({
color: disabled ? colors.grey[400] : colors.grey[700],
height: textHidden ? 32 : 20,
paddingTop: textHidden ? 8 : 0,
"& .MuiSvgIcon-root": {
width: 18,
height: 18,
},
}))
const Text = styled("div")(({ theme }) => ({
const Text = styled("div")(({ theme, disabled }) => ({
fontWeight: "bold",
fontSize: 11,
color: colors.grey[800],
color: disabled ? colors.grey[500] : colors.grey[800],
display: "flex",
alignItems: "center",
lineHeight: 1,
Expand All @@ -61,11 +61,11 @@ export const HeaderButton = ({
<ThemeProvider theme={theme}>
<StyledButton onClick={onClick} disabled={disabled}>
<ButtonInnerContent>
<IconContainer textHidden={hideText}>
<IconContainer textHidden={hideText} disabled={disabled}>
{icon || getIcon(name, customIconMapping)}
</IconContainer>
{!hideText && (
<Text>
<Text disabled={disabled}>
<div>{name}</div>
</Text>
)}
Expand Down