RENAMED: From checkbox-layout -> input-layout

ADDED: Slider componnet (without styles and functionality)
CHANGED: segmented-button styles
This commit is contained in:
doryan04 2024-02-12 21:55:58 +04:00
parent d94e1b7360
commit 6493687fdf
10 changed files with 44 additions and 40 deletions

View File

@ -11,6 +11,7 @@ import { CardActionArea } from '../src/primitive-components/card/card-action-are
import { Button } from '../src/primitive-components/button-components/button/button'; import { Button } from '../src/primitive-components/button-components/button/button';
import { SegmentButton } from '../src/primitive-components/button-components/segmented-buttons/segment-button'; import { SegmentButton } from '../src/primitive-components/button-components/segmented-buttons/segment-button';
import { SegmentedButtons } from '../src/primitive-components/button-components/segmented-buttons/segmented-buttons'; import { SegmentedButtons } from '../src/primitive-components/button-components/segmented-buttons/segmented-buttons';
import {Slider} from "../src/primitive-components/input-components/slider/slider";
export default function Page() { export default function Page() {
return ( return (
@ -69,6 +70,7 @@ export default function Page() {
</SegmentButton> </SegmentButton>
<SegmentButton>Label 3</SegmentButton> <SegmentButton>Label 3</SegmentButton>
</SegmentedButtons> </SegmentedButtons>
<Slider />
<Checkbox /> <Checkbox />
</div> </div>
</CardFooter> </CardFooter>

View File

@ -4,7 +4,7 @@ import { bool } from 'prop-types';
import { CheckboxProps } from './checkbox.types'; import { CheckboxProps } from './checkbox.types';
import { RippleEffect } from '../../ripple/ripple-effect'; import { RippleEffect } from '../../ripple/ripple-effect';
import useRippleEffect from '../../ripple/hooks/useRippleEffect'; import useRippleEffect from '../../ripple/hooks/useRippleEffect';
import { CheckBoxLayout } from '../checkbox-layout/check-box-layout'; import { InputLayout } from '../input-layout/input-layout';
import { import {
forwardRef, forwardRef,
useEffect, useEffect,
@ -37,7 +37,7 @@ export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
return ( return (
<label {...events} className={extraClassStyles}> <label {...events} className={extraClassStyles}>
<CheckBoxLayout <InputLayout
{...props} {...props}
indeterminate={props.indeterminate} indeterminate={props.indeterminate}
ref={checkboxRef} ref={checkboxRef}

View File

@ -7,9 +7,9 @@ import React, {
useRef, useRef,
} from 'react'; } from 'react';
import { bool, string } from 'prop-types'; import { bool, string } from 'prop-types';
import { CheckboxLayoutProps } from './checkbox-layout.types'; import { InputLayoutProps } from './input-layout.types';
export const CheckBoxLayout = forwardRef<HTMLInputElement, CheckboxLayoutProps>( export const InputLayout = forwardRef<HTMLInputElement, InputLayoutProps>(
({ indeterminate, typeInput, type, ...props }, ref) => { ({ indeterminate, typeInput, type, ...props }, ref) => {
const checkboxRef = useRef<HTMLInputElement>(null); const checkboxRef = useRef<HTMLInputElement>(null);
@ -37,7 +37,7 @@ export const CheckBoxLayout = forwardRef<HTMLInputElement, CheckboxLayoutProps>(
}, },
); );
CheckBoxLayout.propTypes = { InputLayout.propTypes = {
typeInput: string, typeInput: string,
indeterminate: bool, indeterminate: bool,
}; };

View File

@ -1,6 +1,6 @@
import { InputHTMLAttributes } from 'react'; import { InputHTMLAttributes } from 'react';
export interface CheckboxLayoutProps export interface InputLayoutProps
extends InputHTMLAttributes<HTMLInputElement> { extends InputHTMLAttributes<HTMLInputElement> {
indeterminate?: boolean; indeterminate?: boolean;
typeInput?: string; typeInput?: string;

View File

@ -5,7 +5,7 @@ import { RadioProps } from './radio.types';
import { RippleEffect } from '../../ripple/ripple-effect'; import { RippleEffect } from '../../ripple/ripple-effect';
import { forwardRef, useRef, useState } from 'react'; import { forwardRef, useRef, useState } from 'react';
import useRippleEffect from '../../ripple/hooks/useRippleEffect'; import useRippleEffect from '../../ripple/hooks/useRippleEffect';
import { CheckBoxLayout } from '../checkbox-layout/check-box-layout'; import { InputLayout } from '../input-layout/input-layout';
/** /**
* Radio component * Radio component
@ -23,7 +23,7 @@ export const Radio = forwardRef<HTMLInputElement, RadioProps>(
return ( return (
<div {...events} className={extraClassStyles}> <div {...events} className={extraClassStyles}>
<CheckBoxLayout {...props} ref={ref} type={'radio'} /> <InputLayout {...props} ref={ref} type={'radio'} />
<span className={'m3 m3-radio-state-layer'} /> <span className={'m3 m3-radio-state-layer'} />
<svg height={'20px'} viewBox={'0 0 20 20'} width={'20px'}> <svg height={'20px'} viewBox={'0 0 20 20'} width={'20px'}>
<circle <circle

View File

@ -0,0 +1,9 @@
import React, { forwardRef, HTMLAttributes } from 'react';
import { InputLayout } from '../input-layout/input-layout';
export const Slider = forwardRef<
HTMLInputElement,
HTMLAttributes<HTMLInputElement>
>((props, ref) => {
return <InputLayout ref={ref} type={'range'} />;
});

View File

@ -3,8 +3,8 @@
import { bool } from 'prop-types'; import { bool } from 'prop-types';
import React, { forwardRef } from 'react'; import React, { forwardRef } from 'react';
import { SwitchMainProps } from './switch.types'; import { SwitchMainProps } from './switch.types';
import { CheckBoxLayout } from '../checkbox-layout/check-box-layout'; import { InputLayout } from '../input-layout/input-layout';
import { LabelPlacement } from '../checkbox-layout/checkbox-layout.types'; import { LabelPlacement } from '../input-layout/input-layout.types';
/** /**
* Switch component * Switch component
@ -16,7 +16,7 @@ export const Switch = forwardRef<
SwitchMainProps & LabelPlacement SwitchMainProps & LabelPlacement
>(({ icon, selected = false, ...props }, ref) => ( >(({ icon, selected = false, ...props }, ref) => (
<div className={'m3 m3-switch'}> <div className={'m3 m3-switch'}>
<CheckBoxLayout <InputLayout
{...props} {...props}
className={`m3 ${props.className ?? ''}`.trimEnd()} className={`m3 ${props.className ?? ''}`.trimEnd()}
ref={ref} ref={ref}

View File

@ -8,24 +8,21 @@ div.m3.m3-segmented-buttons
border-collapse: collapse border-collapse: collapse
& > button.m3.m3-button-segment & > button.m3.m3-button-segment
margin: 0 -0.5px 0 -0.5px
& > button.m3.m3-button-segment:first-child
border-radius: 20px 0 0 20px
& > button.m3.m3-button-segment:last-child
border-radius: 0 20px 20px 0
& > button.m3.m3-button-segment
height: 40px height: 40px
display: flex display: flex
min-width: 108px min-width: 108px
border-radius: 0
width: max-content width: max-content
padding-inline: 10px padding-inline: 10px
margin: 0 -0.5px 0 -0.5px
background-color: transparent
border: 1px solid var(--md-sys-color-outline) border: 1px solid var(--md-sys-color-outline)
& &:first-child
border-radius: 0 border-radius: 20px 0 0 20px
background-color: transparent
&:last-child
border-radius: 0 20px 20px 0
& > span & > span
color: var(--md-sys-color-on-surface) color: var(--md-sys-color-on-surface)
@ -36,11 +33,11 @@ div.m3.m3-segmented-buttons
&.selected &.selected
background-color: var(--md-sys-color-secondary-container) background-color: var(--md-sys-color-secondary-container)
&.selected > span & > span
color: var(--md-sys-color-on-secondary-container) color: var(--md-sys-color-on-secondary-container)
&.selected > svg > text & > text
fill: var(--md-sys-color-on-secondary-container) fill: var(--md-sys-color-on-secondary-container)
& > span.m3.m3-button-segment-state-layer & > span.m3.m3-button-segment-state-layer
position: absolute position: absolute

View File

@ -731,7 +731,15 @@ div.m3.m3-segmented-buttons {
border-collapse: collapse; border-collapse: collapse;
} }
div.m3.m3-segmented-buttons > button.m3.m3-button-segment { div.m3.m3-segmented-buttons > button.m3.m3-button-segment {
height: 40px;
display: flex;
min-width: 108px;
border-radius: 0;
width: max-content;
padding-inline: 10px;
margin: 0 -0.5px 0 -0.5px; margin: 0 -0.5px 0 -0.5px;
background-color: transparent;
border: 1px solid var(--md-sys-color-outline);
} }
div.m3.m3-segmented-buttons > button.m3.m3-button-segment:first-child { div.m3.m3-segmented-buttons > button.m3.m3-button-segment:first-child {
border-radius: 20px 0 0 20px; border-radius: 20px 0 0 20px;
@ -739,18 +747,6 @@ div.m3.m3-segmented-buttons > button.m3.m3-button-segment:first-child {
div.m3.m3-segmented-buttons > button.m3.m3-button-segment:last-child { div.m3.m3-segmented-buttons > button.m3.m3-button-segment:last-child {
border-radius: 0 20px 20px 0; border-radius: 0 20px 20px 0;
} }
div.m3.m3-segmented-buttons > button.m3.m3-button-segment {
height: 40px;
display: flex;
min-width: 108px;
width: max-content;
padding-inline: 10px;
border: 1px solid var(--md-sys-color-outline);
}
div.m3.m3-segmented-buttons > button.m3.m3-button-segment {
border-radius: 0;
background-color: transparent;
}
div.m3.m3-segmented-buttons > button.m3.m3-button-segment > span { div.m3.m3-segmented-buttons > button.m3.m3-button-segment > span {
color: var(--md-sys-color-on-surface); color: var(--md-sys-color-on-surface);
} }
@ -763,7 +759,7 @@ div.m3.m3-segmented-buttons > button.m3.m3-button-segment.selected {
div.m3.m3-segmented-buttons > button.m3.m3-button-segment.selected > span { div.m3.m3-segmented-buttons > button.m3.m3-button-segment.selected > span {
color: var(--md-sys-color-on-secondary-container); color: var(--md-sys-color-on-secondary-container);
} }
div.m3.m3-segmented-buttons > button.m3.m3-button-segment.selected > svg > text { div.m3.m3-segmented-buttons > button.m3.m3-button-segment.selected > span > text {
fill: var(--md-sys-color-on-secondary-container); fill: var(--md-sys-color-on-secondary-container);
} }
div.m3.m3-segmented-buttons > button.m3.m3-button-segment > span.m3.m3-button-segment-state-layer { div.m3.m3-segmented-buttons > button.m3.m3-button-segment > span.m3.m3-button-segment-state-layer {

File diff suppressed because one or more lines are too long