I assume the key was on and engine was running.
If Battery light is on when key is on then Alternator is off.
Like before you start the engine, turn key on and Battery Light should be on.
When engine starts and alternator is turning and producing 13.5-14.5volts the Battery Light will go off.
Dash lights powered by 12volt battery power will be dimmer than with 13.5volts alternator power.
Dash lights dimmed and battery light came on because alternator stopped generating voltage.
Why?
Don't know
I would first check wires on alternator, clean and tight.
2007 Ranger has a "Smart Charging" junction box with 2 fuses, these feed the instrument cluster and battery light.
Diagram here:
http://www.justanswer.com/ford/4gj2l-2007-ford-ranger-4-0l-not-charging-w-new-alternator-the-two.html
An alternator is the same as an electric motor, if left on it will drain the battery, so an alternator has an ON/OFF switch, that switch is the Battery Light circuit.
When you turn the key on, 12v flows thru the battery light bulb to the alternator, the alternator is not producing power so it is the same as a Ground(0 volts), since voltage is flowing from 12volts to 0 volts the light bulb glows(battery Light is on).
Once alternator starts to spin it produces power, 13.5volts, so the Battery Light has 13.5v on one leg(from key) and 13.5v on the other leg(at alternator) so no power is flowing thru the bulb(Battery Light is Off)