Skip to content

Commit

Permalink
Merge pull request #1299 from nsbno/new-servicealert-variant
Browse files Browse the repository at this point in the history
New ServiceAlert variant
  • Loading branch information
hanrog authored Nov 14, 2024
2 parents 0ed3e06 + 67d767a commit d70eada
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 25 deletions.
8 changes: 8 additions & 0 deletions .changeset/tiny-swans-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@vygruppen/spor-react": minor
"@vygruppen/spor-icon": minor
"@vygruppen/spor-icon-react": minor
"@vygruppen/spor-icon-react-native": minor
---

new variant for ServiceAlert
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/spor-icon/svg/feedback/service-fill-18x18.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/spor-icon/svg/feedback/service-fill-24x24.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/spor-icon/svg/feedback/service-fill-30x30.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/spor-icon/svg/feedback/service-outline-18x18.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/spor-icon/svg/feedback/service-outline-24x24.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/spor-icon/svg/feedback/service-outline-30x30.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion packages/spor-react/src/alert/AlertIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import React from "react";
import { createTexts, useTranslation } from "../i18n";
import { BaseAlertProps } from "./BaseAlert";
import { ServiceFill24Icon } from "@vygruppen/spor-icon-react/tmp";

type AlertIconProps = { variant: BaseAlertProps["variant"] };
/**
Expand Down Expand Up @@ -39,8 +40,10 @@ const getIcon = (variant: BaseAlertProps["variant"]) => {
return AltTransportOutline24Icon;
case "error":
return ErrorOutline24Icon;
case "service":
case "global-deviation":
return WarningFill24Icon;
case "service":
return ServiceFill24Icon;
}
};

Expand Down Expand Up @@ -81,4 +84,10 @@ const texts = createTexts({
sv: "Servicemeddelande",
en: "Service message",
},
"global-deviation": {
nb: "Trafikkmelding",
nn: "Trafikkmelding",
sv: "Trafikmeddelande",
en: "Traffic announcement",
},
});
3 changes: 2 additions & 1 deletion packages/spor-react/src/alert/BaseAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export type BaseAlertProps = BoxProps & {
| "warning"
| "alt-transport"
| "error"
| "service";
| "service"
| "global-deviation";
/** The body content of the alert */
children: React.ReactNode;
/** The title of the alert */
Expand Down
16 changes: 10 additions & 6 deletions packages/spor-react/src/alert/ServiceAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type ServiceAlertProps = BaseAlertProps & {
*
* Defaults to h3 */
headingLevel?: "h2" | "h3" | "h4" | "h5" | "h6";
/** The variant of Service Alert. Default: service */
variant?: "service" | "global-deviation";
};
/**
* A service alert component.
Expand All @@ -46,7 +48,7 @@ type ServiceAlertProps = BaseAlertProps & {
* ```
*/
export const ServiceAlert = ({
variant,
variant = "service",
children,
title,
notification,
Expand All @@ -56,9 +58,8 @@ export const ServiceAlert = ({
onToggle = () => {},
...boxProps
}: ServiceAlertProps) => {
variant = "service";
const { t } = useTranslation();
const styles = useMultiStyleConfig("AlertService");
const styles = useMultiStyleConfig("AlertService", { variant });
return (
<BaseAlert
variant={variant}
Expand Down Expand Up @@ -101,7 +102,6 @@ export const ServiceAlert = ({
WebkitLineClamp: "1",
WebkitBoxOrient: "vertical",
}}
color="white"
>
{title}
</Box>
Expand All @@ -114,7 +114,7 @@ export const ServiceAlert = ({
</Text>
)}

<AccordionIcon color="white" />
<AccordionIcon />
</Flex>
</Flex>
</Stack>
Expand All @@ -132,7 +132,11 @@ export const ServiceAlert = ({
sx={{
p: {
padding: "0.8rem 0",
borderBottom: "0.08rem solid rgba(255, 255, 255, 0.4)",
borderBottom: "0.08rem solid",
borderColor:
variant === "global-deviation"
? "blackAlpha.400"
: "whiteAlpha.400",
},
"p:last-child": {
borderBottom: "none",
Expand Down
56 changes: 46 additions & 10 deletions packages/spor-react/src/theme/components/alert-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const parts = anatomy("alertService").parts(
"serviceMessageContent",
);
const helpers = createMultiStyleConfigHelpers(parts.keys);

const config = helpers.defineMultiStyleConfig({
baseStyle: {
container: {
Expand All @@ -21,23 +20,15 @@ const config = helpers.defineMultiStyleConfig({
borderBottomRadius: "md",
_hover: {
outline: "2px solid",
outlineColor: "blueGreen",
},
_active: {
backgroundColor: "pine",
outlineColor: "pine",
},
},
outerBox: {
outline: "1px solid",
outlineColor: "blueGreen",
backgroundColor: "darkTeal",
borderBottomRadius: "md",
borderTopRadius: "none",
width: "100%",
},
notificationText: {
color: "white",
fontWeight: "400",
fontSize: "1rem",
pr: "0.375rem",
Expand All @@ -46,7 +37,52 @@ const config = helpers.defineMultiStyleConfig({
paddingX: "0.75rem",
paddingTop: "0.375rem",
paddingBottom: "0.9375rem",
color: "white",
},
},
variants: {
"global-deviation": {
container: {
_hover: {
outlineColor: "primrose",
},
_active: {
backgroundColor: "blonde",
outlineColor: "primrose",
},
color: "darkGrey",
},
outerBox: {
outlineColor: "primrose",
backgroundColor: "blonde",
},
notificationText: {
color: "darkGrey",
},
serviceMessageContent: {
color: "darkGrey",
},
},
service: {
container: {
_hover: {
outlineColor: "blueGreen",
},
_active: {
backgroundColor: "pine",
outlineColor: "pine",
},
color: "white",
},
outerBox: {
outlineColor: "blueGreen",
backgroundColor: "darkTeal",
},
notificationText: {
color: "white",
},
serviceMessageContent: {
color: "white",
},
},
},
});
Expand Down
5 changes: 5 additions & 0 deletions packages/spor-react/src/theme/components/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ const config = helpers.defineMultiStyleConfig({
backgroundColor: "banana",
},
},
"global-deviation": {
container: {
backgroundColor: "blonde",
},
},
service: {
container: {
backgroundColor: "darkTeal",
Expand Down

0 comments on commit d70eada

Please sign in to comment.