-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement placeholder action buttons on StopDetails page
* Placeholder button for: Edit Stop validity period and/or priority. * Proper: OpenOnMap -button. * ExtraActions -menu with: - Placeholder meny items for: Make a new copy of stop -menu action.
- Loading branch information
1 parent
26574c0
commit 6f037d1
Showing
7 changed files
with
147 additions
and
8 deletions.
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
36 changes: 36 additions & 0 deletions
36
ui/src/components/stop-registry/stops/stop-details/title-row/EditValidityButton.tsx
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { FC } from 'react'; | ||
import { twMerge } from 'tailwind-merge'; | ||
import { StopWithDetails } from '../../../../../hooks'; | ||
|
||
const DISABLE_UNTIL_IMPLEMENTED = true; | ||
|
||
const testIds = { | ||
button: 'StopDetailsPage::editValidityButton', | ||
}; | ||
|
||
type EditValidityButtonProps = { | ||
readonly className?: string; | ||
readonly stop: StopWithDetails | null; | ||
}; | ||
|
||
export const EditValidityButton: FC<EditValidityButtonProps> = ({ | ||
className, | ||
stop, | ||
}) => { | ||
return ( | ||
<button | ||
className={twMerge( | ||
'h-11 w-11', | ||
'flex items-center justify-center', | ||
'rounded-full border border-grey', | ||
'disabled:pointer-events-none disabled:bg-background disabled:opacity-70', | ||
className, | ||
)} | ||
data-testid={testIds.button} | ||
disabled={!stop || DISABLE_UNTIL_IMPLEMENTED} | ||
type="button" | ||
> | ||
<i className="icon-calendar aria-hidden text-2xl text-brand" /> | ||
</button> | ||
); | ||
}; |
47 changes: 47 additions & 0 deletions
47
ui/src/components/stop-registry/stops/stop-details/title-row/ExtraActions.tsx
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import noop from 'lodash/noop'; | ||
import { FC } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { twJoin } from 'tailwind-merge'; | ||
import { StopWithDetails } from '../../../../../hooks'; | ||
import { | ||
AlignDirection, | ||
SimpleDropdownMenu, | ||
SimpleDropdownMenuItem, | ||
} from '../../../../../uiComponents'; | ||
|
||
const DISABLE_UNTIL_IMPLEMENTED = true; | ||
|
||
const testIds = { | ||
actionMenu: 'StopDetailsPage::extraActions::menu', | ||
copy: 'StopDetailsPage::extraActions::copy', | ||
}; | ||
|
||
type ExtraActionsProps = { | ||
readonly className?: string; | ||
readonly stop: StopWithDetails | null; | ||
}; | ||
|
||
export const ExtraActions: FC<ExtraActionsProps> = ({ className, stop }) => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<SimpleDropdownMenu | ||
className={className} | ||
buttonClassName={twJoin( | ||
'flex h-11 w-11 items-center justify-center border border-grey', | ||
'disabled:pointer-events-none disabled:bg-background disabled:opacity-70', | ||
)} | ||
tooltip={t('accessibility:common.actionMenu')} | ||
alignItems={AlignDirection.Left} | ||
testId={testIds.actionMenu} | ||
disabled={!stop} | ||
> | ||
<SimpleDropdownMenuItem | ||
text={t('stopDetails.actions.extra.copy')} | ||
disabled={DISABLE_UNTIL_IMPLEMENTED} | ||
onClick={noop} | ||
testId={testIds.copy} | ||
/> | ||
</SimpleDropdownMenu> | ||
); | ||
}; |
36 changes: 36 additions & 0 deletions
36
ui/src/components/stop-registry/stops/stop-details/title-row/OpenOnMapButton.tsx
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { FC } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { twMerge } from 'tailwind-merge'; | ||
import { StopWithDetails } from '../../../../../hooks'; | ||
import { LocatorButton } from '../../../../../uiComponents'; | ||
import { useOpenStopOnMap } from '../../../search/StopTableRow/utils'; | ||
|
||
type OpenOnMapButtonProps = { | ||
readonly className?: string; | ||
readonly label: string; | ||
readonly stop: StopWithDetails | null; | ||
}; | ||
|
||
export const OpenOnMapButton: FC<OpenOnMapButtonProps> = ({ | ||
className, | ||
label, | ||
stop, | ||
}) => { | ||
const { t } = useTranslation(); | ||
|
||
const openStopOnMap = useOpenStopOnMap(); | ||
const onClick = () => { | ||
if (stop && stop.stop_place !== null) { | ||
openStopOnMap({ ...stop, stop_place: stop.stop_place }); | ||
} | ||
}; | ||
|
||
return ( | ||
<LocatorButton | ||
className={twMerge('h-11 w-11', className)} | ||
disabled={!stop} | ||
onClick={onClick} | ||
tooltipText={t('accessibility:common.showOnMap', { label })} | ||
/> | ||
); | ||
}; |
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
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