Skip to content
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

Changing font & color - Exploring presetWebFonts preset #159

Closed
jd-solanki opened this issue Apr 12, 2023 Discussed in #158 · 16 comments
Closed

Changing font & color - Exploring presetWebFonts preset #159

jd-solanki opened this issue Apr 12, 2023 Discussed in #158 · 16 comments
Labels

Comments

@jd-solanki
Copy link
Owner

Discussed in #158

Originally posted by Sandros94 April 11, 2023
I noticed that the scss from the presetThemeDefault applies the Inter font:

$body-color: hsla(var(--a-base-c), 0.68);
$body-font-family: 'Inter', sans-serif;
$header-font-family: $body-font-family;

body {
background-color: hsl(var(--a-body-bg-c));
color: $body-color;
// Disable mobile tap blue color
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
font-family: $body-font-family;
}
h1,
h2,
h3,
h4,
h5,
h6 {
color: hsla(var(--a-base-c), 0.87);
font-family: $header-font-family;
}

Can I change it from uno.config.ts or should I just overwrite the body and heading styles?

@sandros94
Copy link
Contributor

If I can help you just ping me.
I'm not that great with js/ts yet, but I'm learning and I'm starting to get a decent knowledge of Nuxt 3

@jd-solanki
Copy link
Owner Author

oh, So nice of you 🙏🏻

Sure, I will let you know 😇

@jd-solanki
Copy link
Owner Author

Hey @sandros94

Thanks for your patience and reporting the issue. Anu now no longer handles the font-family customization, Instead we now allow using presetWebFonts for fetching & changing the font-family.

From the next release (now on, if you are using edge releases) you will be able to customize the fonts via web fonts UnoCSS preset.

For color, We now have CSS variable for each theme so that can you can have different color for each theme: https://github.com/jd-solanki/anu/blob/main/packages/anu-vue/src/plugin.ts#L39

Please let me know your thoughts on this.

@sandros94
Copy link
Contributor

I'll checkout the edge release as soon as I get back home/office. The changes look perfect already ♥️

@sandros94
Copy link
Contributor

In the end its quite late here and I'll check it out tomorrow.

But while thinking about it I've come to notice that I don't have a clear understanding on how to change the color (or add a new one) only using uno.config.ts (in a nuxt project). At the point where reading the docs I'm doubting it.

@sandros94
Copy link
Contributor

sandros94 commented Apr 20, 2023

EDIT

just read your last comment on the other issue:

Due to some issues, action wasn't able to make a edge release to test the latest release I said about. I will let you know once edge release will continue to work.


I was creating a test branch to test this, under the same branch for #155. But then I got distracted on new info for that issue.

Anyway, here is the new test branch, and I need your help to understand how to use Anu with presetWebFonts and customize Anu's colors via uno.config.ts.

As you can see in that branch I still need to specify the changes as css:

<style>
body {
    color: hsla(var(--a-base-c), 1.0);
    @apply bg-white dark:bg-#101010 font-sans;
}
h1, h2, h3, h4, h5, h6 {
    color: inherit;
    @apply font-sans;
}
</style>

even though I do have the presetWebFonts configured correctly:

export default defineConfig({
    [...]
    presets: [
        [...]
        presetWebFonts({
            fonts: {
                sans: 'Jost:100,200,300,400,500,600,700,800,900',
                mono: ['Fira Code:400,500,600,700', 'Fira Mono:400,500,600,700']
            },
        }),
        [...]
})

while for the color configuration of the Anu theme, as I said in the last comment, I really didn't understand how to do it in the uno.config.ts.

I would like to understand these a bit more, so that I could potentially improve the Anu documentation, especially for newcomers like me that don't have all that experience (yet).


P.S.: I did try out the useAnu composable but I feel like that is more for a different usecase.
In my situation I preferred to customize all my UnoCSS and Anu inside the uno.config.ts and use useAnu only on those deployments that I let the user customize the colors during production.

@jd-solanki
Copy link
Owner Author

Hi, I have made a new release. Can you please give it a try?

@sandros94
Copy link
Contributor

I've tested v0.14.0 and indeed it picks up the presetWebFonts conifgs. (still testing on the linked branch)
But I'm probably doing something wrong because I still need to specify in the vue style to apply the unocss font-sans.

Another thing that is still not clear to me on how to customize my presetAnu:
I do personally like creating boilerplates for potential future projects, where I don't much need changing variables at runtime but I do need to edit my configs while still on dev. What would be the process (or syntax) to edit my presetAnu config to change things like how a-base-c is applied to headings, or defining a secondary color without the use of useAnu, since I do not need to change it in runtime.

One last thing:
I'm noticing that in the unocss conifg now I get a warning regarding types when importing presetAnu from anu-vue

Could not find a declaration file for module 'anu-vue'. 'c:/GitHub/Sandros94/test-nuxt3app/node_modules/anu-vue/dist/anu-vue.umd.cjs' implicitly has an 'any' type.
Try npm i --save-dev @types/anu-vue if it exists or add a new declaration (.d.ts) file containing declare module 'anu-vue';ts(7016)

@jd-solanki
Copy link
Owner Author

jd-solanki commented May 19, 2023

I still need to specify in the vue style to apply the unocss font-sans

You mean you still have to write font-family: 'xxx', right? If yes, That happened to me as well. Maybe we have to first test if this is from UnoCSS or not.

how to customize my presetAnu

I'm willing to add docs for this. If you have something to ask regarding this, let's discuss this in discord thread.

I get a warning

🤔 Strange, I'll look into this

@sandros94
Copy link
Contributor

You mean you still have to write font-family: 'xxx', right? Maybe we have to first test if this is from UnoCSS or not.

Yes, and indeed this is the case: on a fresh unocss install (without anu) I have to specify the font-family (even for sans).

I'm willing to add docs for this. If you have something to ask regarding this, let's discuss this in discord thread.

Sounds good, later I'll open the discussion there.

@jd-solanki
Copy link
Owner Author

I have to specify the font-family

Can you please raise issue on uno repo and reference here for tracking?

@sandros94
Copy link
Contributor

Can you please raise issue on uno repo and reference here for tracking?

it has been a busy day, doing it now.

@jd-solanki
Copy link
Owner Author

Hi @sandros94 Apart from mentioned issue. I think everything is resolved now from Anu's side, Am I right?

@sandros94
Copy link
Contributor

I would say yes. We'll see how it goes there from this point on.

@sandros94
Copy link
Contributor

@jd-solanki following the reply we got there I would close this issue as fully completed now.

@jd-solanki
Copy link
Owner Author

@sandros94 Yes, Let's close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants