<commit_before>import * as React from 'react';

import { useAtomValue } from 'jotai/utils';
import { CSSInterpolation } from 'tss-react';
import { equals } from 'ramda';

import {
  ThemeProvider as MuiThemeProvider,
  Theme,
  StyledEngineProvider,
  createTheme,
  InputBaseProps,
  ButtonProps,
} from '@mui/material';
import { autocompleteClasses } from '@mui/material/Autocomplete';
import { ThemeOptions } from '@mui/material/styles/createTheme';

import { ThemeMode, userAtom } from '@centreon/ui-context';

import { getPalette } from './palettes';

declare module '@mui/styles/defaultTheme' {
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
  interface DefaultTheme extends Theme {}
}

declare module '@mui/material/TextField' {
  interface TextFieldPropsSizeOverrides {
    compact: true;
  }
}

const getInputBaseRootStyle = ({ size }: InputBaseProps): CSSInterpolation => {
  if (equals(size, 'compact')) {
    return {
      fontSize: 'x-small',
      minHeight: '32px',
    };
  }
  if (equals(size, 'small')) {
    return {
      minHeight: '36px',
    };
  }

  return {
    minHeight: '48px',
  };
};

const getButtonRootStyle = ({ size }: ButtonProps): CSSInterpolation => {
  if (equals(size, 'small')) {
    return {
      height: '36px',
    };
  }
  if (equals(size, 'large')) {
    return {
      height: '48px',
    };
  }

  return {
    height: '40px',
  };
};

export const getTheme = (mode: ThemeMode): ThemeOptions => ({
  components: {
    MuiButton: {
      styleOverrides: {
        root: ({ ownerState }) => getButtonRootStyle(ownerState),
      },
    },
    MuiChip: {
      styleOverrides: {
        root: ({ ownerState, theme }) => ({
          ...(equals(ownerState.size, 'medium') && {
            borderRadius: theme.spacing(1.25),
            fontSize: theme.typography.body2.fontSize,
            height: theme.spacing(2.5),
            lineHeight: theme.spacing(2.5),
            minWidth: theme.spacing(2.5),
          }),
          ...(equals(ownerState.size, 'small') && {
            borderRadius: theme.spacing(0.75),
            fontSize: theme.typography.caption.fontSize,
            height: theme.spacing(1.5),
            lineHeight: theme.spacing(1.5),<commit_msg>change the default size of the buttons (#273)<commit_after>import * as React from 'react';

import { useAtomValue } from 'jotai/utils';
import { CSSInterpolation } from 'tss-react';
import { equals } from 'ramda';

import {
  ThemeProvider as MuiThemeProvider,
  Theme,
  StyledEngineProvider,
  createTheme,
  InputBaseProps,
  ButtonProps,
} from '@mui/material';
import { autocompleteClasses } from '@mui/material/Autocomplete';
import { ThemeOptions } from '@mui/material/styles/createTheme';

import { ThemeMode, userAtom } from '@centreon/ui-context';

import { getPalette } from './palettes';

declare module '@mui/styles/defaultTheme' {
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
  interface DefaultTheme extends Theme {}
}

declare module '@mui/material/TextField' {
  interface TextFieldPropsSizeOverrides {
    compact: true;
  }
}

const getInputBaseRootStyle = ({ size }: InputBaseProps): CSSInterpolation => {
  if (equals(size, 'compact')) {
    return {
      fontSize: 'x-small',
      minHeight: '32px',
    };
  }
  if (equals(size, 'small')) {
    return {
      minHeight: '36px',
    };
  }

  return {
    minHeight: '48px',
  };
};

const getButtonRootStyle = ({ size }: ButtonProps): CSSInterpolation => {
  if (equals(size, 'medium')) {
    return {
      height: '40px',
    };
  }
  if (equals(size, 'large')) {
    return {
      height: '48px',
    };
  }

  return {
    height: '36px',
  };
};

export const getTheme = (mode: ThemeMode): ThemeOptions => ({
  components: {
    MuiButton: {
      styleOverrides: {
        root: ({ ownerState }) => getButtonRootStyle(ownerState),
      },
    },
    MuiChip: {
      styleOverrides: {
        root: ({ ownerState, theme }) => ({
          ...(equals(ownerState.size, 'medium') && {
            borderRadius: theme.spacing(1.25),
            fontSize: theme.typography.body2.fontSize,
            height: theme.spacing(2.5),
            lineHeight: theme.spacing(2.5),
            minWidth: theme.spacing(2.5),
          }),
          ...(equals(ownerState.size, 'small') && {
            borderRadius: theme.spacing(0.75),
            fontSize: theme.typography.caption.fontSize,
            height: theme.spacing(1.5),
            lineHeight: theme.spacing(1.5),
{'fraction_non_alphanumeric': 0.14754825826492124, 'fraction_numerical': 0.013534501885955182, 'mean_word_length': 2.8010118043844856, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7652393', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1430, 'n_words': 290}