gloriasoft / veaury

Use React in Vue3 and Vue3 in React, And as perfect as possible!
MIT License
1.31k stars 83 forks source link

Elastic UI CSS missalignement #6

Closed AimSteyz closed 2 years ago

AimSteyz commented 2 years ago

Hi again,

So this is the follow of the #5 issue, the CSS cant align correctly, i've try modifying the CSS file "@elastic/eui/dist/eui_theme_light.css" but it does'nt seems to work

Here is what I have Vuer

And the same component in React Reacter

devilwjp commented 2 years ago

@AimSteyz I compared your two pictures, and I found that the font style and border style are different, which means that a basic style is missing.

Is the React component displayed in another React project, or in a Vue project?

Because different projects have their own different basic styles.

And I also found that in the example of elastic_ui's combo-box, there is a public style with a button selector , and this button selector is not included in @elastic/eui/dist/eui_theme_light.css.

In this page (https://elastic.github.io/eui/#/forms/combo-box), when I cancel the padding property in this public button selector in the debug style panel, it is not centered. image

AimSteyz commented 2 years ago

The style are differents but it is the same CSS file imported for each The screen is from the same component but in react so it the "same" things Screenshot from 2022-05-05 14-57-54

But modifying the css in the vue project didnt impact the display even if it work when unclicking the box on your picture Screenshot from 2022-05-05 14-58-19

devilwjp commented 2 years ago

@AimSteyz I mean, the reason why this icon cannot be centered is not the width attribute, but the default padding of the browser's button tag is 6px, you only need to set the padding and margin of the browser's default button to 0px, and it will be centered , such as the following example.

button {
    background: none;
    border: none;
    padding: 0px;
    margin: 0px;
    color: inherit;
    border-radius: 0px;
    font-size: inherit;
}
AimSteyz commented 2 years ago

Oh ok i understand sorry, but this is not a button that i create, this is a component from a lib, so this is not a button that i have create here is all my file to get this code : tmp

devilwjp commented 2 years ago

I think it may be that vue3's vite template project lacks style rewriting for button tags. You can try adding a style tag to this vue file and add the button style I provided above.

AimSteyz commented 2 years ago

Ok thank you

devilwjp commented 2 years ago

@AimSteyz

Aha! I found the cause of the problem, you should use EuiProvider in the outermost layer.

<script setup>
import '@elastic/eui/dist/eui_theme_light.css';
import { ref } from 'vue';
import { appendIconComponentCache } from '@elastic/eui/es/components/icon/icon';
import { icon as arrowDown } from '@elastic/eui/es/components/icon/assets/arrow_down';
import { icon as returnKey } from '@elastic/eui/es/components/icon/assets/return_key';
import { EuiComboBox, EuiProvider } from '@elastic/eui';
import { applyReactInVue } from 'veaury'

const EuiProviderVue = applyReactInVue(EuiProvider)
const optionsStatic = ref([]);

appendIconComponentCache({
  arrowDown,
  returnKey
});
const EuiComboBoxVue = applyReactInVue(EuiComboBox)
</script>

<template>
  <EuiProviderVue colorMode="light">
    <EuiComboBoxVue
        aria-label="Accessible screen reader label"
        placeholder="Select or create options"
        :options="optionsStatic"
        :isClearable="true"
        data-test-subj="demoComboBox"
        :autoFocus="true"
    />
  </EuiProviderVue>
</template>

image

AimSteyz commented 2 years ago
<script setup>
import '@elastic/eui/dist/eui_theme_light.css';
import { ref } from 'vue';
import { appendIconComponentCache } from '@elastic/eui/es/components/icon/icon';
import { icon as arrowDown } from '@elastic/eui/es/components/icon/assets/arrow_down';
import { icon as returnKey } from '@elastic/eui/es/components/icon/assets/return_key';
import { EuiComboBox, EuiProvider } from '@elastic/eui';
import { applyReactInVue } from 'veaury'

const EuiProviderVue = applyReactInVue(EuiProvider)
const optionsStatic = ref([]);

appendIconComponentCache({
  arrowDown,
  returnKey
});
const EuiComboBoxVue = applyReactInVue(EuiComboBox)
</script>

<template>
  <EuiProviderVue colorMode="light">
    <EuiComboBoxVue
        aria-label="Accessible screen reader label"
        placeholder="Select or create options"
        :options="optionsStatic"
        :isClearable="true"
        data-test-subj="demoComboBox"
        :autoFocus="true"
    />
  </EuiProviderVue>
</template>

Waho, thank you ! I close the issue, Thank you very much !