Skip to content

Commit

Permalink
Merge pull request #2455 from coingaming/MDS-721
Browse files Browse the repository at this point in the history
fix: add Input to Docs, align colours [MDS-721]
  • Loading branch information
dkireev authored Oct 31, 2023
2 parents fbefb96 + 60aea27 commit 22a9cb6
Show file tree
Hide file tree
Showing 19 changed files with 56 additions and 48 deletions.
2 changes: 1 addition & 1 deletion docs/app/components/server/accordion/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import QuickNav from '@/app/components/shared/QuickNav';
import { getExamples } from '@/app/utils/getExamples';
import { MDX } from '@/components/MDX';

export default async function Home() {
export default async function Accordion() {
const { server } = await getExamples();
const examplesList = Object.keys(server.accordion.examples);
return (
Expand Down
2 changes: 1 addition & 1 deletion docs/app/components/server/button/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import QuickNav from '@/app/components/shared/QuickNav';
import { getExamples } from '@/app/utils/getExamples';
import { MDX } from '@/components/MDX';

export default async function Home() {
export default async function Button() {
const { server } = await getExamples();
const examplesList = Object.keys(server.button.examples);
return (
Expand Down
2 changes: 0 additions & 2 deletions docs/app/components/server/checkbox/examples/Default.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Checkbox from '@heathmont/moon-base-tw/lib/checkbox/Checkbox';

export const Default = () => <Checkbox />;

export default Default;
2 changes: 1 addition & 1 deletion docs/app/components/server/checkbox/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import QuickNav from '@/app/components/shared/QuickNav';
import { getExamples } from '@/app/utils/getExamples';
import { MDX } from '@/components/MDX';

export default async function Home() {
export default async function Checkbox() {
const { server } = await getExamples();
const examplesList = Object.keys(server.checkbox.examples);
return (
Expand Down
2 changes: 0 additions & 2 deletions docs/app/components/server/chip/examples/Default.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Chip from '@heathmont/moon-base-tw/lib/chip/Chip';

export const Default = () => <Chip>Default</Chip>;

export default Default;
2 changes: 1 addition & 1 deletion docs/app/components/server/chip/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import QuickNav from '@/app/components/shared/QuickNav';
import { getExamples } from '@/app/utils/getExamples';
import { MDX } from '@/components/MDX';

export default async function Home() {
export default async function Chip() {
const { server } = await getExamples();
const examplesList = Object.keys(server.chip.examples);
return (
Expand Down
3 changes: 3 additions & 0 deletions docs/app/components/server/input/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Text input fields allow users to enter text and can be used to collect user feedback or enter information in data entry forms.

These types of input fields are used on their own, or in combination with other inputs such as number entry, date picker, etc.
3 changes: 3 additions & 0 deletions docs/app/components/server/input/examples/Default.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Input from '@heathmont/moon-base-tw/lib/input/Input';

export const Default = () => <Input aria-label="default" />;
22 changes: 22 additions & 0 deletions docs/app/components/server/input/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Default } from '@/app/components/server/input/examples/Default';
import ExampleSection from '@/app/components/shared/ExampleSection';
import QuickNav from '@/app/components/shared/QuickNav';
import { getExamples } from '@/app/utils/getExamples';
import { MDX } from '@/components/MDX';

export default async function Input() {
const { server } = await getExamples();
const examplesList = Object.keys(server.input.examples);
return (
<div className="w-full max-w-7xl flex flex-col gap-4 text-moon-14">
<h1 className="font-medium text-moon-32">Input</h1>
<MDX markdown={server.input.description} />
<QuickNav items={examplesList} />
<ExampleSection
title="Default"
component={<Default />}
code={server.input.examples.Default}
/>
</div>
);
}
2 changes: 0 additions & 2 deletions docs/app/components/server/loader/examples/Default.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Loader from '@heathmont/moon-base-tw/lib/loader/Loader';

export const Default = () => <Loader />;

export default Default;
2 changes: 1 addition & 1 deletion docs/app/components/server/loader/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import QuickNav from '@/app/components/shared/QuickNav';
import { getExamples } from '@/app/utils/getExamples';
import { MDX } from '@/components/MDX';

export default async function Home() {
export default async function Loader() {
const { server } = await getExamples();
const examplesList = Object.keys(server.loader.examples);
return (
Expand Down
6 changes: 6 additions & 0 deletions docs/app/components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ export interface Examples {
Default: 'string';
};
};
input: {
description: 'string';
examples: {
Default: 'string';
};
};
loader: {
description: 'string';
examples: {
Expand Down
4 changes: 2 additions & 2 deletions workspaces/base/src/chip/Chip.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { forwardRef } from 'react';
import type ChipProps from './private/types/ChipProps';
import setPadding from './private/utils/setPadding';
import getPadding from './private/utils/getPadding';
import mergeClassnames from '../mergeClassnames/mergeClassnames';

const Chip = forwardRef<HTMLButtonElement, ChipProps>(
Expand Down Expand Up @@ -28,7 +28,7 @@ const Chip = forwardRef<HTMLButtonElement, ChipProps>(
'hover:text-piccolo user-select-none',
iconOnly ? 'center' : 'space-between',
size === 'sm' ? 'h-8 gap-1' : 'h-10 gap-2',
setPadding({ size, iconLeft, iconRight, iconOnly }),
getPadding({ size, iconLeft, iconRight, iconOnly }),
variant === 'ghost' ? '' : 'bg-goku',
isActive ? 'bg-jiren text-piccolo' : 'text-bulma',
isStroke && 'hover:shadow-interactive',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type ChipProps from '../types/ChipProps';

const setPadding = ({
const getPadding = ({
size,
iconLeft,
iconRight,
Expand Down Expand Up @@ -30,4 +30,4 @@ const setPadding = ({
return `p-2`;
};

export default setPadding;
export default getPadding;
4 changes: 2 additions & 2 deletions workspaces/base/src/input/Input.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { forwardRef } from 'react';
import mergeClassnames from '../mergeClassnames/mergeClassnames';
import getSizeStyles from './private/getSizeStyles';
import mergeClassnames from '../mergeClassnames/mergeClassnames';

export interface InputProps
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'> {
Expand All @@ -23,7 +23,7 @@ const InputPure = forwardRef<HTMLInputElement, InputProps>(
disabled={disabled}
className={mergeClassnames(
'block w-full max-w-full py-0 px-4 m-0 appearance-none text-[1rem] text-bulma transition-shadow box-border relative z-[2]',
'bg-gohan shadow-input hover:shadow-input-hov',
'bg-goku shadow-input hover:shadow-input-hov',
'focus:shadow-input-focus focus:outline-none',
'focus-visible::shadow-input-focus focus-visible::outline-none',
error &&
Expand Down
20 changes: 0 additions & 20 deletions workspaces/base/src/input/private/makeBorder.ts

This file was deleted.

14 changes: 7 additions & 7 deletions workspaces/base/src/loader/Loader.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import type LoaderProps from './private/types/LoaderProps';
import setDivBorder from './private/utils/setDivBorder';
import setSize from './private/utils/setSize';
import getDivBorder from './private/utils/getDivBorder';
import getSize from './private/utils/getSize';
import mergeClassnames from '../mergeClassnames/mergeClassnames';

const Loader = ({
Expand All @@ -13,11 +13,11 @@ const Loader = ({
aria-label={ariaLabel}
role="alert"
aria-busy="true"
className={mergeClassnames(setSize(size), 'relative rounded-full')}
className={mergeClassnames(getSize(size), 'relative rounded-full')}
>
<div
className={mergeClassnames(
setDivBorder(size),
getDivBorder(size),
color,
'absolute w-full h-full rounded-full animate-[rotation_1.2s_cubic-bezier(0.5,0,0.5,1)_infinite] border-x-transparent border-b-transparent'
)}
Expand All @@ -26,7 +26,7 @@ const Loader = ({
/>
<div
className={mergeClassnames(
setDivBorder(size),
getDivBorder(size),
color,
'absolute w-full h-full rounded-full animate-[rotation_1.2s_cubic-bezier(0.5,0,0.5,1)_infinite] border-x-transparent border-b-transparent'
)}
Expand All @@ -35,7 +35,7 @@ const Loader = ({
/>
<div
className={mergeClassnames(
setDivBorder(size),
getDivBorder(size),
color,
'absolute w-full h-full rounded-full animate-[rotation_1.2s_cubic-bezier(0.5,0,0.5,1)_infinite] border-x-transparent border-b-transparent'
)}
Expand All @@ -44,7 +44,7 @@ const Loader = ({
/>
<div
className={mergeClassnames(
setDivBorder(size),
getDivBorder(size),
color,
'absolute w-full h-full rounded-full animate-[rotation_1.2s_cubic-bezier(0.5,0,0.5,1)_infinite] border-x-transparent border-b-transparent'
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type LoaderSize from '../types/LoaderSize';

const setDivBorder = (size?: LoaderSize) => {
const getDivBorder = (size?: LoaderSize) => {
switch (size) {
case '2xs':
case 'xs':
Expand All @@ -11,4 +11,4 @@ const setDivBorder = (size?: LoaderSize) => {
}
};

export default setDivBorder;
export default getDivBorder;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type LoaderSize from '../types/LoaderSize';

const setSize = (size?: LoaderSize) => {
const getSize = (size?: LoaderSize) => {
switch (size) {
case '2xs':
return 'w-4 h-4';
Expand All @@ -15,4 +15,4 @@ const setSize = (size?: LoaderSize) => {
}
};

export default setSize;
export default getSize;

0 comments on commit 22a9cb6

Please sign in to comment.