-
-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]: Select, Calendar, DropDown by default set dir to ltr even when html dir is rtl #719
Comments
You need to wrap your app around with We can add some guide for user concern about |
Seems fine but that should be reactive correct me if am wrong but i think that the |
@lord007tn what do you mean "should be reactive". It is reactive Can you explain more what is "multi-direction website", and what is the expected outcome that you are looking for? |
From my understanding, I think that @lord007tn is suggesting that CSS should handle directionality based on the root element, rather than using JavaScript ( With this approach, by only changing the |
I like the idea instead of My idea is to use |
@sadeghbarati useTextDirection composable these are the defaults: export interface UseTextDirectionOptions extends ConfigurableDocument {
/**
* CSS Selector for the target element applying to
*
* @default 'html'
*/
selector?: string
/**
* Observe `document.querySelector(selector)` changes using MutationObserve
*
* @default false
*/
observe?: boolean
/**
* Initial value
*
* @default 'ltr'
*/
initialValue?: UseTextDirectionValue
} We could use UpdateThere is this issue of first render on SSR and what |
I believe we can have this feature in |
Very well then! The Challenge here is how to Using Wrapper Component (Current Implementation)<script setup lang="ts">
import { ConfigProvider } from 'radix-vue'
</script>
<template>
<ConfigProvider initialDir="ltr">
<slot />
</ConfigProvider>
</template> We would only need to rename Using Vue PluginBy using a plugin we could provide a global configuration, from vue docs, one of the use cases for vue plugins are:
user would create such plugin and this value would be used as import { createRadixConfig } from "radix-vue"
import { createApp } from 'vue'
import App from './App.vue'
import './style.css'
const radixConfig = createRadixConfig({
initialDir: 'ltr',
})
createApp(App)
.use(radixConfig)
.mount('#app') I'd personally recommend going this direction as it has no overhead of a render-less component and aligns better with vue itself, IMO using Provider components are better left in react, as far a I know bigger parts of vue ecosystem does not follow Provider component pattern. Let me know your thoughts and if this sound OK to you, I'd be happy to helping execute this idea. |
Thanks for awesome suggestion @Saeid-Za ! The reason with Even though we can export a custom provide function to provide and inject similar config, but the idea of "wrapping" with components is more appealing to me. What do you think? |
@zernonia Considering the the fact that Nevertheless, ConfigProvider could not be replaced which i thought it could, here's an idea, why not support both approaches? With this new approach, the flexibility of current implementation is preserved and any plan for adding nuxt module level configuration would be open. |
We can do that @Saeid-Za . However, I also thought about another possible solution, we can utilize This way it offers much more flexibility to the user, also support Vite/Nuxt. |
Since users should always provide something to the provider for direction to work, it seems that there is no way around it. There is no code changes required right? |
Yup. I think so. We can add a guide to the doc about "internationalization (RTL)" 👍🏻 Would really appreciate if you can help with this 😁 With your knowledge with RTL I believe it would be easy |
Sure ! |
* docs: adding docs, resolves #719 * docs: minor change --------- Co-authored-by: zernonia <[email protected]>
Reproduction
https://codesandbox.io/p/devbox/shadcn-vue-selectdemo-forked-gxptxq
Describe the bug
I set global dir for html to be
dir='rtl'
Select, calendar, dropdown seems to have a default
dir='ltr'
so everytime i should force them to bedir='auto'
so they can have parent HTML dirit seems like auto is not a valid value in radix components
so we need to support it in shadcn components as default value
System Info
Contributes
The text was updated successfully, but these errors were encountered: