I've taken a long hiatus from intellectual Reddit, but appreciate the callback! Time to wade back in:
/u/Okleconservative, I really can't recommend strongly enough the sources flagged in my linked answer (also listed below).
But I warn you, they're going to challenge the premise of your question. It's not quite fair to say the Democrats "supported segregation and slavery" -- unless you go back before 1900 -- because the parties weren't anywhere near as ideologically rigid in the civil rights era, and the politics of race were excruciatingly complicated. To build his civil rights-reform coalition, for example, Lyndon Johnson had to meld bicoastal "Rockefeller Republicans" with progressive Democrats, while placating segregationist Democrats, like his mentor Richard B. Russell. That means it's also not quite fair to say Republicans "opposed" Democrats on civil rights.
None of that fits neatly into a talking point, so you'll see this history oversimplified (by both parties) quite frequently! Some good books for further reading, and what part of your question each answers:
Not discouraging other responses here, but this is a fairly frequent question in this sub, so you can get started on some previous responses.
In this thread, /u/OldWorldGlory highlights the threads in the FAQ, and /u/AmesCG adds further info How did the (US) Democratic and Republican parties get to their current political platforms?
Here's the most recent comment on the question, by /u/njwillforever, in In the time of the American Civil War Democratic Party was more conservative, e.g. against the abolition of slavery, and Republican Party was more progressive. Why and when did their programs change to opposites, to today programs?