Plans for 15 new flats to be built above a library and shops in a town have been given the green light by a council.