Skip to content

Commit

Permalink
fix: added option to override the slide button container
Browse files Browse the repository at this point in the history
  • Loading branch information
pksorensen committed Sep 6, 2024
1 parent 0b28486 commit 8a0417c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
9 changes: 5 additions & 4 deletions packages/core/src/components/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import React, { PropsWithChildren } from "react";
import { MouseEventHandler, useEffect, useState } from "react";
import { quickformtokens } from "../../style/quickFormTokensDefinition";
import { makeStyles, shorthands } from "@griffel/react";
import { makeStyles, mergeClasses, shorthands } from "@griffel/react";

type BtnContainerProps = {
readonly buttonClassName?: string;
readonly className?: string;
readonly style?: React.CSSProperties;
readonly disabled?: boolean;
Expand Down Expand Up @@ -37,7 +38,7 @@ const useButtonStyles = makeStyles({
}
})

export const Button: React.FC<PropsWithChildren<BtnContainerProps>> = ({ children, showPressEnter, onClick, disabled, visible, style }) => {
export const Button: React.FC<PropsWithChildren<BtnContainerProps>> = ({ children, showPressEnter, onClick, disabled, visible, style, className, buttonClassName }) => {

if (typeof visible !== "undefined" && visible === false) {
return (<></>);
Expand All @@ -60,9 +61,9 @@ export const Button: React.FC<PropsWithChildren<BtnContainerProps>> = ({ childre
}, []);

return (
<div className={styles.container}>
<div className={mergeClasses(styles.container, className)}>
<button
className={styles.button}
className={mergeClasses(styles.button, buttonClassName)}
style={style}
disabled={disabled}
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ import { useQuickForm } from '../../../state/QuickFormContext';
import { Button, Slide } from '../../index';
import { useHandleEnterKeypress } from '../../../hooks';
import { quickformtokens } from "../../../style";
import { mergeClasses } from '@griffel/react';
import { makeStyles, mergeClasses } from '@griffel/react';
import { IconResolver } from '../../icons/IconResolver';
import { SlideModel } from '../../../model';

const useSlideRenderStyles = makeStyles({
button: { display: 'flex', alignItems: 'center', justifyContent: 'center' }
});

export const SlideRenderer: React.FC = () => {

const { state, goToNextSlide } = useQuickForm();
const [className, setClassName] = useState(state.classes.slide);
const styles = useSlideRenderStyles();

const currentSlide: SlideModel = state.slides[state.currIdx];

Expand Down Expand Up @@ -47,7 +51,8 @@ export const SlideRenderer: React.FC = () => {
>
<Slide model={currentSlide} />
<Button
style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}
className={state.classes.slideButtonContainer}
buttonClassName={mergeClasses(styles.button, state.classes.slideButton)}
onClick={goToNextSlide}
showPressEnter={showPressEnter}
children={
Expand Down
10 changes: 9 additions & 1 deletion packages/core/src/state/QuickformState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ import { SlideModel } from "../model/SlideModel";
import { LayoutDefinition, QuickFormModel } from "../model";
import { IconType } from "../components/icons/IconResolver";

export type QuickformClassNames = { slide: string, slideIsIn: string, slideIsOut: string, submit:string, ending:string };
export type QuickformClassNames = {
slide: string,
slideButton: string,
slideButtonContainer: string;
slideIsIn: string,
slideIsOut: string,
submit: string,
ending: string
};
export type QuickformState = {
autoAdvanceSlides?: boolean;
enableQuestionNumbers?: boolean;
Expand Down

0 comments on commit 8a0417c

Please sign in to comment.