I'm unclear on exactly when to use a comma or a period before a quotation. It's obvious if what comes before is a simple dialogue tag like "He said," but consider the following examples:
- Mike was afraid to ask his next question. "Why?"
- John sighed before answering. "Because it's my birthday."
- Mike continued his line of inquiry. "I don't see how that matters."
- James raised a glass. "Cheers."
- "Stay out of it, James," said Mike with a glare before turning back to John and pressing him further. "It's my birthday too."
I've included periods in all of them (which I personally think works best) but I'm not sure if some or all should technically be commas instead. Is it just a matter of preference and style?