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

Overriding header arrow font (DatePicker component) #49

Closed
amadeann opened this issue Jan 31, 2018 · 10 comments
Closed

Overriding header arrow font (DatePicker component) #49

amadeann opened this issue Jan 31, 2018 · 10 comments
Assignees

Comments

@amadeann
Copy link

Is there a 'native' way to override the font used in the header arrow? I would like to use consistent arrows across the page, and the only way I came up with was to hardcode it this way in my stylesheet:

.vc-angle-left::before {
    content: "my_new_arrow" !important;
}

I know I can customize e.g. the font size using the headerArrows property of themeStyles, but how can I style the pseudo element ::before with it?

@nathanreyes
Copy link
Owner

nathanreyes commented Feb 2, 2018

To replace the arrows, I would use the header-left-button and header-right-button slots. Be sure to call the provided page methods on click. You can then style your arrows any way you like.

Here is a fiddle that might help.

<v-calendar>
  <a
    slot='header-left-button'
    slot-scope='{ page }'
    @click='page.movePrevMonth()'>
    Prev
  </a>
  <a
    slot='header-right-button'
    slot-scope='{ page }'
    @click='page.moveNextMonth()'>
    Next
  </a>
</v-calendar>

@amadeann
Copy link
Author

amadeann commented Feb 4, 2018

Thank you for your answer @nathanreyes.

I forgot to mention that I am using DatePicker component, not the calendar (I edited the issue title). Unfortunately, it doesn't work. Here's a slightly changed fiddle:

https://jsfiddle.net/y0t3fznc/

I think the problem is that DatePicker component doesn't implement Calendar component directly, but delegates it to either SingleDatePicker, MultipleDatePicker, or DateRangePicker. Slots don't seem to be passed down to 'grandchildren'.

@amadeann amadeann changed the title Overriding header arrow font Overriding header arrow font (DatePicker component) Feb 4, 2018
@nathanreyes
Copy link
Owner

Ah, yes, slots aren't currently passed down for the date picker. To get back to your original question, you can't target pseudo-elements with inline styes. That is one of the drawbacks to using them.

Your original hard-coded approach will have to suffice for now until the date picker supports passing down slots.

@nathanreyes
Copy link
Owner

Thinking I may just implement v-date-picker using render functions to make this possible.

@nathanreyes nathanreyes self-assigned this Feb 6, 2018
@ezhkov
Copy link

ezhkov commented Feb 16, 2018

Hello. Thank you for great component!

Is there any progress implementing DatePicker slots customization?

@nathanreyes
Copy link
Owner

Yes, this is in the works. Been busy the last few weeks but will most likely be in the next revision.

@amadeann
Copy link
Author

Thank you for fixing this in 0.7.0. (Somehow this issue wasn't linked to the mention in changelog).

@amadeann
Copy link
Author

Also, just realized, the example you posted needs to be tweaked a bit to work (removed object destructuring):

<v-calendar>
    <a
        slot='header-left-button'
        slot-scope='page'
        @click='page.movePrevMonth()'>
        Prev
    </a>
    <a
        slot='header-right-button'
        slot-scope='page'
        @click='page.moveNextMonth()'>
        Next
    </a>
</v-calendar>

@Sovai
Copy link

Sovai commented Jun 14, 2023

any update? 3.0.3 still cannot has scrope slot events or disabled

@nebojsa91markovic
Copy link

I successfully customized arrow icons in my Vue application using SCSS. Here's a breakdown of the steps I took:

  1. Hide Polylines: I concealed the polyline since it wasn't being overwritten.
  2. Import SVG Icon: I incorporated my SVG icon using the background-image property. Optionally, you can specify colors directly using properties like fill, stroke, and stroke-width.
  3. Apply Filter for Current Color: To allow dynamic coloring of the SVG icon across the app, I used the filter property. This ensured that the fill="currentColor" attribute in my icon would adapt to different colors set elsewhere in the application. If your icon already has a fixed color, using the filter might not be necessary.
  4. Adjust Disabled Icon Color: By default, the library set the color of disabled icons to opacity: 0.25. I wanted a different color, so I overrode it to opacity: 1. Additionally, I applied a filter to maintain consistency with the color theme.

Here's the refined SCSS code:

  :deep(.vc-header .vc-prev .vc-base-icon polyline) {
    display: none;
  }
  :deep(.vc-header .vc-next .vc-base-icon),
  :deep(.vc-header .vc-prev .vc-base-icon) {
    width: 24px;
    height: 9px;
    background-image: url('../../assets/icons/forwardArrow.svg');
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    filter: invert(21%) sepia(94%) saturate(2450%) hue-rotate(188deg) brightness(96%) contrast(118%);
  }

  :deep(.vc-header .vc-prev .vc-base-icon) {
    transform: rotate(180deg);
  }

  :deep(.vc-header .vc-arrow:disabled) {
    opacity: 1;
    filter: invert(16%) sepia(12%) saturate(15%) hue-rotate(94deg) brightness(94%) contrast(87%);
  } ```

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

No branches or pull requests

5 participants